diff --git a/Content.Client/EntryPoint.cs b/Content.Client/EntryPoint.cs index 9ddf27ee63..6711cb3dc7 100644 --- a/Content.Client/EntryPoint.cs +++ b/Content.Client/EntryPoint.cs @@ -25,6 +25,13 @@ namespace Content.Client factory.RegisterIgnore("PowerStorage"); factory.RegisterIgnore("PowerGenerator"); + factory.RegisterIgnore("Wirecutter"); + factory.RegisterIgnore("Screwdriver"); + factory.RegisterIgnore("Multitool"); + factory.RegisterIgnore("Welder"); + factory.RegisterIgnore("Wrench"); + factory.RegisterIgnore("Crowbar"); + factory.Register(); factory.RegisterReference(); diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj index 175c3cc462..6c291fde4c 100644 --- a/Content.Server/Content.Server.csproj +++ b/Content.Server/Content.Server.csproj @@ -57,6 +57,13 @@ + + + + + + + @@ -108,7 +115,5 @@ - - - + \ No newline at end of file diff --git a/Content.Server/EntryPoint.cs b/Content.Server/EntryPoint.cs index dc5ca3636e..926ec0c334 100644 --- a/Content.Server/EntryPoint.cs +++ b/Content.Server/EntryPoint.cs @@ -1,6 +1,7 @@  using Content.Server.GameObjects; using Content.Server.GameObjects.Components.Power; +using Content.Server.GameObjects.Components.Interactable.Tools; using Content.Server.Interfaces.GameObjects; using SS14.Server; using SS14.Server.Interfaces; @@ -8,7 +9,6 @@ using SS14.Server.Interfaces.Chat; using SS14.Server.Interfaces.Maps; using SS14.Server.Interfaces.Player; using SS14.Server.Player; -using SS14.Shared; using SS14.Shared.Console; using SS14.Shared.ContentPack; using SS14.Shared.Enums; @@ -57,12 +57,22 @@ namespace Content.Server factory.Register(); factory.Register(); factory.Register(); + + //Power Components factory.Register(); factory.Register(); factory.Register(); factory.Register(); factory.Register(); factory.Register(); + + //Tools + factory.Register(); + factory.Register(); + factory.Register(); + factory.Register(); + factory.Register(); + factory.Register(); } /// diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/BaseTool.cs b/Content.Server/GameObjects/Components/Interactable/Tools/BaseTool.cs new file mode 100644 index 0000000000..f7019178e4 --- /dev/null +++ b/Content.Server/GameObjects/Components/Interactable/Tools/BaseTool.cs @@ -0,0 +1,31 @@ +using SS14.Shared.GameObjects; +using SS14.Shared.Utility; +using YamlDotNet.RepresentationModel; + +namespace Content.Server.GameObjects.Components.Interactable.Tools +{ + public abstract class ToolComponent : Component + { + /// + /// For tool interactions that have a delay before action this will modify the rate, time to wait is divided by this value + /// + public float SpeedModifier { get; set; } = 1; + + public override void LoadParameters(YamlMappingNode mapping) + { + if (mapping.TryGetNode("Speed", out YamlNode node)) + { + SpeedModifier = node.AsFloat(); + } + } + + /// + /// Status modifier which determines whether or not we can act as a tool at this time + /// + /// + public virtual bool CanUse() + { + return true; + } + } +} diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs new file mode 100644 index 0000000000..12b2a8cea3 --- /dev/null +++ b/Content.Server/GameObjects/Components/Interactable/Tools/CrowbarComponent.cs @@ -0,0 +1,10 @@ +namespace Content.Server.GameObjects.Components.Interactable.Tools +{ + public class CrowbarComponent : ToolComponent + { + /// + /// Tool that can be used to crowbar things apart, such as deconstructing + /// + public override string Name => "Crowbar"; + } +} \ No newline at end of file diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/MultitoolComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/MultitoolComponent.cs new file mode 100644 index 0000000000..92f1972962 --- /dev/null +++ b/Content.Server/GameObjects/Components/Interactable/Tools/MultitoolComponent.cs @@ -0,0 +1,10 @@ +namespace Content.Server.GameObjects.Components.Interactable.Tools +{ + /// + /// Tool used for interfacing/hacking into configurable computers + /// + public class MultitoolComponent : ToolComponent + { + public override string Name => "Multitool"; + } +} \ No newline at end of file diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/ScrewdriverComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/ScrewdriverComponent.cs new file mode 100644 index 0000000000..9095a3b2c8 --- /dev/null +++ b/Content.Server/GameObjects/Components/Interactable/Tools/ScrewdriverComponent.cs @@ -0,0 +1,10 @@ +namespace Content.Server.GameObjects.Components.Interactable.Tools +{ + public class ScrewdriverComponent : ToolComponent + { + /// + /// Tool that interacts with technical components that need to be screwed in + /// + public override string Name => "Screwdriver"; + } +} \ No newline at end of file diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs new file mode 100644 index 0000000000..afc2cda12f --- /dev/null +++ b/Content.Server/GameObjects/Components/Interactable/Tools/WelderComponent.cs @@ -0,0 +1,129 @@ +using System; +using SS14.Shared.Interfaces.GameObjects; +using SS14.Shared.Utility; +using YamlDotNet.RepresentationModel; +using SS14.Server.GameObjects; + +namespace Content.Server.GameObjects.Components.Interactable.Tools +{ + /// + /// Tool used to weld metal together, light things on fire, or melt into constituent parts + /// + class WelderComponent : ToolComponent, EntitySystems.IUse + { + public override string Name => "Welder"; + + /// + /// Maximum fuel capacity the welder can hold + /// + public float FuelCapacity { get; set; } = 50; + + /// + /// Fuel the welder has to do tasks + /// + public float Fuel { get; set; } = 0; + + /// + /// Default Cost of using the welder fuel for an action + /// + public const float DefaultFuelCost = 5; + + /// + /// Rate at which we expunge fuel from ourselves when activated + /// + public const float FuelLossRate = 0.2f; + + /// + /// Status of welder, whether it is ignited + /// + public bool Activated { get; private set; } = false; + + //private string OnSprite { get; set; } + //private string OffSprite { get; set; } + + public override void LoadParameters(YamlMappingNode mapping) + { + base.LoadParameters(mapping); + + if (mapping.TryGetNode("Capacity", out YamlNode node)) + { + FuelCapacity = node.AsFloat(); + } + + //if (mapping.TryGetNode("On", out node)) + //{ + // OnSprite = node.AsString(); + //} + + //if (mapping.TryGetNode("Off", out node)) + //{ + // OffSprite = node.AsString(); + //} + + if (mapping.TryGetNode("Fuel", out node)) + { + Fuel = node.AsFloat(); + } + else + { + Fuel = FuelCapacity; + } + } + + public override void Update(float frameTime) + { + Fuel = Math.Min(Fuel - FuelLossRate, 0); + + if(Activated && Fuel == 0) + { + ToggleStatus(); + } + } + + public bool CanUse(float value) + { + return Fuel > value; + } + + public override bool CanUse() + { + return CanUse(DefaultFuelCost); + } + + public bool CanActivate() + { + return Fuel > 0; + } + + public bool UseEntity(IEntity user) + { + return ToggleStatus(); + } + + /// + /// Deactivates welding tool if active, activates welding tool if possible + /// + /// + public bool ToggleStatus() + { + if(Activated) + { + Activated = false; + + //TODO : Change sprite on deactivation + return true; + } + else if(CanActivate()) + { + Activated = true; + + //TODO : Change sprite on activation + return true; + } + else + { + return false; + } + } + } +} diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/WirecutterComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/WirecutterComponent.cs new file mode 100644 index 0000000000..8f7edaa0d3 --- /dev/null +++ b/Content.Server/GameObjects/Components/Interactable/Tools/WirecutterComponent.cs @@ -0,0 +1,10 @@ +namespace Content.Server.GameObjects.Components.Interactable.Tools +{ + /// + /// Tool that can be used for some cutting interactions such as wires or hacking + /// + public class WirecutterComponent : ToolComponent + { + public override string Name => "Wirecutter"; + } +} \ No newline at end of file diff --git a/Content.Server/GameObjects/Components/Interactable/Tools/WrenchComponent.cs b/Content.Server/GameObjects/Components/Interactable/Tools/WrenchComponent.cs new file mode 100644 index 0000000000..1b69b39ee9 --- /dev/null +++ b/Content.Server/GameObjects/Components/Interactable/Tools/WrenchComponent.cs @@ -0,0 +1,10 @@ +namespace Content.Server.GameObjects.Components.Interactable.Tools +{ + /// + /// Wrenches bolts, and interacts with things that have been bolted + /// + public class WrenchComponent : ToolComponent + { + public override string Name => "Wrench"; + } +} \ No newline at end of file diff --git a/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs index bf78a116ee..b1870f5e10 100644 --- a/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs @@ -49,7 +49,7 @@ namespace Content.Server.GameObjects.EntitySystems public void UserInteraction(object sender, EntityEventArgs arg) { ClickedOnEntityEventArgs e = (ClickedOnEntityEventArgs)arg; - if (e.MouseButton != Clicktype.Left) + if (e.MouseButton != ClickType.Left) return; IEntity user = EntityManager.GetEntity(e.Clicker); diff --git a/Resources/Prototypes/Entities/Tools.yml b/Resources/Prototypes/Entities/Tools.yml new file mode 100644 index 0000000000..284f634bac --- /dev/null +++ b/Resources/Prototypes/Entities/Tools.yml @@ -0,0 +1,71 @@ +- type: entity + name: Wirecutter + parent: BaseItem + id: Wirecutter + components: + - type: Wirecutter + - type: WearableAnimatedSprite + notWornSprite: wirecutter + sprite: wirecutter + - type: Icon + icon: wirecutter + +- type: entity + name: Screwdriver + parent: BaseItem + id: Screwdriver + components: + - type: Screwdriver + - type: WearableAnimatedSprite + notWornSprite: screwdriver + sprite: screwdriver + - type: Icon + icon: screwdriver + +- type: entity + name: Welder + parent: BaseItem + id: Welder + components: + - type: Welder + - type: WearableAnimatedSprite + notWornSprite: welder + sprite: welder + - type: Icon + icon: welder + +- type: entity + name: Wrench + parent: BaseItem + id: Wrench + components: + - type: Wrench + - type: WearableAnimatedSprite + notWornSprite: wrench + sprite: wrench + - type: Icon + icon: wrench + +- type: entity + name: Crowbar + parent: BaseItem + id: Crowbar + components: + - type: Crowbar + - type: WearableAnimatedSprite + notWornSprite: crowbar + sprite: crowbar + - type: Icon + icon: crowbar + +- type: entity + name: Multitool + parent: BaseItem + id: Multitool + components: + - type: Multitool + - type: WearableAnimatedSprite + notWornSprite: multitool + sprite: multitool + - type: Icon + icon: multitool \ No newline at end of file diff --git a/Resources/textures/Objects/crowbar.png b/Resources/textures/Objects/crowbar.png new file mode 100644 index 0000000000..ac25643123 Binary files /dev/null and b/Resources/textures/Objects/crowbar.png differ diff --git a/Resources/textures/Objects/multitool.png b/Resources/textures/Objects/multitool.png new file mode 100644 index 0000000000..0a89791312 Binary files /dev/null and b/Resources/textures/Objects/multitool.png differ diff --git a/Resources/textures/Objects/screwdriver.png b/Resources/textures/Objects/screwdriver.png new file mode 100644 index 0000000000..b200e826b6 Binary files /dev/null and b/Resources/textures/Objects/screwdriver.png differ diff --git a/Resources/textures/Objects/welder.png b/Resources/textures/Objects/welder.png new file mode 100644 index 0000000000..6b1ed2cf13 Binary files /dev/null and b/Resources/textures/Objects/welder.png differ diff --git a/Resources/textures/Objects/wirecutter.png b/Resources/textures/Objects/wirecutter.png new file mode 100644 index 0000000000..08280e16b2 Binary files /dev/null and b/Resources/textures/Objects/wirecutter.png differ diff --git a/Resources/textures/Objects/wrench.png b/Resources/textures/Objects/wrench.png new file mode 100644 index 0000000000..4d24ac7fae Binary files /dev/null and b/Resources/textures/Objects/wrench.png differ