From d7074bf74fcbcdd5c06413432ee82b49bc6de1dd Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Thu, 2 Aug 2018 08:29:55 +0200 Subject: [PATCH] Construction System. (#87) * Construction WiP * Construction kinda works! * Lots more construction work. * It mostly works! --- .../Construction/ConstructionButton.cs | 56 +++ .../Construction/ConstructionMenu.cs | 344 ++++++++++++++++++ .../ConstructionPlacementHijack.cs | 62 ++++ Content.Client/Content.Client.csproj | 8 + Content.Client/EntryPoint.cs | 10 + .../ConstructionGhostComponent.cs | 28 ++ .../Construction/ConstructorComponent.cs | 96 +++++ .../Components/Items/ClientHandsComponent.cs | 2 +- Content.Client/packages.config | 2 +- Content.Server/AI/AimShootLifeProcessor.cs | 15 +- Content.Server/Content.Server.csproj | 6 + Content.Server/EntryPoint.cs | 7 + .../Construction/ConstructionComponent.cs | 175 +++++++++ .../Construction/ConstructorComponent.cs | 98 +++++ .../Components/GUI/InventoryComponent.cs | 5 +- .../Components/GUI/ServerHandsComponent.cs | 5 +- .../Interactable/Tools/WelderComponent.cs | 11 + .../Items/Storage/ServerStorageComponent.cs | 7 +- .../Components/Materials/MaterialComponent.cs | 9 +- .../Components/Power/PowerDebugTool.cs | 3 +- .../Components/Power/PowerDevice.cs | 7 +- .../Components/Power/PowerNodeComponent.cs | 5 +- .../Power/PowerProviderComponent.cs | 3 +- .../Power/PowerTransferComponent.cs | 3 +- .../Components/Stack/StackComponent.cs | 122 +++++++ .../Weapon/Melee/MeleeWeaponComponent.cs | 7 +- .../Ranged/Hitscan/HitscanWeaponComponent.cs | 7 +- .../Ranged/Projectile/ProjectileWeapon.cs | 5 +- .../EntitySystems/Click/ClickParser.cs | 2 +- .../EntitySystems/Click/ExamineSystem.cs | 5 +- .../EntitySystems/Click/InteractionSystem.cs | 14 +- .../GameObjects/EntitySystems/DoorSystem.cs | 2 +- .../EntitySystems/PowerApcSystem.cs | 2 +- .../EntitySystems/PowerSmesSystem.cs | 4 +- .../GameObjects/EntitySystems/PowerSystem.cs | 2 +- .../GameObjects/EntitySystems/WelderSystem.cs | 2 +- .../GameObjects/TemperatureSystem.cs | 2 +- Content.Server/Placement/SpawnHelpers.cs | 8 +- .../Construction/ConstructionPrototype.cs | 221 +++++++++++ Content.Shared/Content.Shared.csproj | 7 +- .../SharedConstructorComponent.cs | 63 ++++ Content.Shared/GameObjects/ContentNetIDs.cs | 1 + Resources/Audio/items/crowbar.ogg | Bin 0 -> 5596 bytes Resources/Audio/items/deconstruct.ogg | Bin 0 -> 8219 bytes Resources/Audio/items/ratchet.ogg | Bin 0 -> 7533 bytes Resources/Audio/items/screwdriver.ogg | Bin 0 -> 12529 bytes Resources/Audio/items/screwdriver2.ogg | Bin 0 -> 4733 bytes Resources/Audio/items/welder.ogg | Bin 0 -> 15662 bytes Resources/Audio/items/welder2.ogg | Bin 0 -> 11513 bytes Resources/Audio/items/wirecutter.ogg | Bin 0 -> 5628 bytes Resources/Audio/items/zip.ogg | Bin 0 -> 11028 bytes .../Prototypes/Construction/machines.yml | 27 ++ Resources/Prototypes/Construction/power.yml | 57 +++ .../Prototypes/Construction/structures.yml | 31 ++ Resources/Prototypes/Construction/weapons.yml | 18 + .../Prototypes/Entities/Construction.yml | 22 ++ Resources/Prototypes/Entities/Materials.yml | 60 +++ Resources/Prototypes/Entities/Mobs.yml | 1 + Resources/Prototypes/Entities/Power.yml | 7 + Resources/Prototypes/Entities/Weapons.yml | 12 + .../Construction/ConstructionButton.tscn | 26 ++ .../Scenes/Construction/ConstructionMenu.tscn | 273 ++++++++++++++ .../Textures/Buildings/smes.rsi/meta.json | 171 +-------- .../Textures/Buildings/smes.rsi/smes.png | Bin 1281 -> 581 bytes Resources/Textures/Buildings/wall_girder.png | Bin 0 -> 302 bytes Resources/Textures/Objects/cable_coil.png | Bin 0 -> 171 bytes .../Objects/lighting.rsi/construct.png | Bin 0 -> 276 bytes .../Textures/Objects/lighting.rsi/empty.png | Bin 0 -> 368 bytes .../Textures/Objects/lighting.rsi/meta.json | 22 +- Resources/Textures/Objects/sheet_glass.png | Bin 0 -> 781 bytes Resources/Textures/Objects/sheet_metal.png | Bin 0 -> 883 bytes Resources/Textures/Objects/spear.png | Bin 0 -> 171 bytes 72 files changed, 1925 insertions(+), 245 deletions(-) create mode 100644 Content.Client/Construction/ConstructionButton.cs create mode 100644 Content.Client/Construction/ConstructionMenu.cs create mode 100644 Content.Client/Construction/ConstructionPlacementHijack.cs create mode 100644 Content.Client/GameObjects/Components/Construction/ConstructionGhostComponent.cs create mode 100644 Content.Client/GameObjects/Components/Construction/ConstructorComponent.cs create mode 100644 Content.Server/GameObjects/Components/Construction/ConstructionComponent.cs create mode 100644 Content.Server/GameObjects/Components/Construction/ConstructorComponent.cs create mode 100644 Content.Server/GameObjects/Components/Stack/StackComponent.cs create mode 100644 Content.Shared/Construction/ConstructionPrototype.cs create mode 100644 Content.Shared/GameObjects/Components/Construction/SharedConstructorComponent.cs create mode 100644 Resources/Audio/items/crowbar.ogg create mode 100644 Resources/Audio/items/deconstruct.ogg create mode 100644 Resources/Audio/items/ratchet.ogg create mode 100644 Resources/Audio/items/screwdriver.ogg create mode 100644 Resources/Audio/items/screwdriver2.ogg create mode 100644 Resources/Audio/items/welder.ogg create mode 100644 Resources/Audio/items/welder2.ogg create mode 100644 Resources/Audio/items/wirecutter.ogg create mode 100644 Resources/Audio/items/zip.ogg create mode 100644 Resources/Prototypes/Construction/machines.yml create mode 100644 Resources/Prototypes/Construction/power.yml create mode 100644 Resources/Prototypes/Construction/structures.yml create mode 100644 Resources/Prototypes/Construction/weapons.yml create mode 100644 Resources/Prototypes/Entities/Construction.yml create mode 100644 Resources/Prototypes/Entities/Materials.yml create mode 100644 Resources/Scenes/Construction/ConstructionButton.tscn create mode 100644 Resources/Scenes/Construction/ConstructionMenu.tscn create mode 100644 Resources/Textures/Buildings/wall_girder.png create mode 100644 Resources/Textures/Objects/cable_coil.png create mode 100644 Resources/Textures/Objects/lighting.rsi/construct.png create mode 100644 Resources/Textures/Objects/lighting.rsi/empty.png create mode 100644 Resources/Textures/Objects/sheet_glass.png create mode 100644 Resources/Textures/Objects/sheet_metal.png create mode 100644 Resources/Textures/Objects/spear.png diff --git a/Content.Client/Construction/ConstructionButton.cs b/Content.Client/Construction/ConstructionButton.cs new file mode 100644 index 0000000000..4b064aa1bb --- /dev/null +++ b/Content.Client/Construction/ConstructionButton.cs @@ -0,0 +1,56 @@ +using Content.Client.GameObjects.Components.Construction; +using SS14.Client.UserInterface; +using SS14.Client.UserInterface.Controls; +using SS14.Shared.Utility; + +namespace Content.Client.Construction +{ + public class ConstructionButton : Button + { + protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Construction/ConstructionButton.tscn"); + + public ConstructorComponent Owner + { + get => Menu.Owner; + set => Menu.Owner = value; + } + ConstructionMenu Menu; + + protected override void Initialize() + { + base.Initialize(); + + OnPressed += IWasPressed; + Menu = new ConstructionMenu(); + Menu.AddToScreen(); + } + + void IWasPressed(ButtonEventArgs args) + { + Menu.Open(); + } + + public void AddToScreen() + { + UserInterfaceManager.StateRoot.AddChild(this); + } + + public void RemoveFromScreen() + { + if (Parent != null) + { + Parent.RemoveChild(this); + } + } + + protected override void Dispose(bool disposing) + { + if (disposing) + { + Menu.Dispose(); + } + + base.Dispose(disposing); + } + } +} diff --git a/Content.Client/Construction/ConstructionMenu.cs b/Content.Client/Construction/ConstructionMenu.cs new file mode 100644 index 0000000000..d2ea12bbce --- /dev/null +++ b/Content.Client/Construction/ConstructionMenu.cs @@ -0,0 +1,344 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Content.Client.GameObjects.Components.Construction; +using Content.Shared.Construction; +using SS14.Client.GameObjects; +using SS14.Client.Graphics; +using SS14.Client.Interfaces.GameObjects; +using SS14.Client.Interfaces.Placement; +using SS14.Client.Interfaces.ResourceManagement; +using SS14.Client.Placement; +using SS14.Client.ResourceManagement; +using SS14.Client.UserInterface; +using SS14.Client.UserInterface.Controls; +using SS14.Client.UserInterface.CustomControls; +using SS14.Client.Utility; +using SS14.Shared.Enums; +using SS14.Shared.Interfaces.GameObjects.Components; +using SS14.Shared.IoC; +using SS14.Shared.Log; +using SS14.Shared.Maths; +using SS14.Shared.Prototypes; +using SS14.Shared.Utility; + +namespace Content.Client.Construction +{ + public class ConstructionMenu : SS14Window + { + protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Construction/ConstructionMenu.tscn"); + +#pragma warning disable CS0649 + [Dependency] + readonly IPrototypeManager PrototypeManager; + [Dependency] + readonly IResourceCache ResourceCache; +#pragma warning restore + + public ConstructorComponent Owner { get; set; } + Button BuildButton; + Button EraseButton; + LineEdit SearchBar; + Tree RecipeList; + TextureRect InfoIcon; + Label InfoLabel; + ItemList StepList; + + CategoryNode RootCategory; + // This list is flattened in such a way that the top most deepest category is first. + List FlattenedCategories; + PlacementManager Placement; + + protected override void Initialize() + { + base.Initialize(); + IoCManager.InjectDependencies(this); + Placement = (PlacementManager)IoCManager.Resolve(); + Placement.PlacementCanceled += OnPlacementCanceled; + + HideOnClose = true; + Title = "Construction"; + Visible = false; + var split = Contents.GetChild("HSplitContainer"); + var rightSide = split.GetChild("Guide"); + var info = rightSide.GetChild("Info"); + InfoIcon = info.GetChild("TextureRect"); + InfoLabel = info.GetChild