Examine System (#65)

* Examine System

* Adds some relevant comments
This commit is contained in:
clusterfack
2018-05-09 09:34:26 -05:00
committed by Pieter-Jan Briers
parent 61a1e769d7
commit 3915b735ae
14 changed files with 148 additions and 5 deletions

View File

@@ -92,6 +92,7 @@
<Compile Include="GameObjects\Components\Weapon\Ranged\RangedWeapon.cs" />
<Compile Include="GameObjects\ContainerSlot.cs" />
<Compile Include="GameObjects\EntitySystems\Click\ClickParser.cs" />
<Compile Include="GameObjects\EntitySystems\Click\ExamineSystem.cs" />
<Compile Include="GameObjects\EntitySystems\Click\InteractionSystem.cs" />
<Compile Include="GameObjects\EntitySystems\PowerSystem.cs" />
<Compile Include="Interfaces\GameObjects\Components\Items\IHandsComponent.cs" />

View File

@@ -3,13 +3,14 @@ using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Utility;
using YamlDotNet.RepresentationModel;
using SS14.Server.GameObjects;
using Content.Server.GameObjects.EntitySystems;
namespace Content.Server.GameObjects.Components.Interactable.Tools
{
/// <summary>
/// Tool used to weld metal together, light things on fire, or melt into constituent parts
/// </summary>
class WelderComponent : ToolComponent, EntitySystems.IUse
class WelderComponent : ToolComponent, EntitySystems.IUse, EntitySystems.IExamine
{
SpriteComponent spriteComponent;
@@ -138,5 +139,14 @@ namespace Content.Server.GameObjects.Components.Interactable.Tools
return false;
}
}
string IExamine.Examine()
{
if(Activated)
{
return "The welding tool is currently lit";
}
return null;
}
}
}

View File

@@ -1,4 +1,5 @@
using SS14.Server.GameObjects;
using Content.Server.GameObjects.EntitySystems;
using SS14.Server.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC;
@@ -12,7 +13,7 @@ namespace Content.Server.GameObjects.Components.Power
/// <summary>
/// Component that requires power to function
/// </summary>
public class PowerDeviceComponent : Component
public class PowerDeviceComponent : Component, EntitySystems.IExamine
{
public override string Name => "PowerDevice";
@@ -134,6 +135,15 @@ namespace Content.Server.GameObjects.Components.Power
}
}
string IExamine.Examine()
{
if(!Powered)
{
return "The device is not powered";
}
return null;
}
private void UpdateLoad(float value)
{
var oldLoad = _load;

View File

@@ -59,7 +59,7 @@ namespace Content.Server.GameObjects.EntitySystems
EntitySystemManager.GetEntitySystem<InteractionSystem>().UserInteraction(message, player);
break;
case (ClickType.Left | ClickType.Shift):
//Examine system
EntitySystemManager.GetEntitySystem<ExamineSystem>().Examine(message, player);
break;
case ClickType.Right:
//Verb System

View File

@@ -0,0 +1,71 @@
using SS14.Server.Interfaces.Chat;
using SS14.Server.Interfaces.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.System;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC;
using SS14.Shared.Log;
using System;
using System.Text;
namespace Content.Server.GameObjects.EntitySystems
{
public interface IExamine
{
/// <summary>
/// Returns an status examine value for components appended to the end of the description of the entity
/// </summary>
/// <returns></returns>
string Examine();
}
public class ExamineSystem : EntitySystem
{
public void Examine(ClickEventMessage msg, IEntity player)
{
//Get entity clicked upon from UID if valid UID, if not assume no entity clicked upon and null
IEntity examined = null;
if (msg.Uid.IsValid())
examined = EntityManager.GetEntity(msg.Uid);
if (examined == null)
return;
//Verify player has a transform component
if (!player.TryGetComponent<IServerTransformComponent>(out var playerTransform))
{
return;
}
//Verify player is on the same map as the entity he clicked on
else if (msg.Coordinates.MapID != playerTransform.MapID)
{
Logger.Warning(string.Format("Player named {0} clicked on a map he isn't located on", player.Name));
return;
}
//Start a stringbuilder since we have no idea how many times this could be appended to
StringBuilder fullexaminetext = new StringBuilder("This is " + examined.Name);
//Add an entity description if one is declared
if(!string.IsNullOrEmpty(examined.Description))
{
fullexaminetext.Append(Environment.NewLine + examined.Description);
}
//Add component statuses from components that report one
foreach (var examinecomponents in examined.GetComponents<IExamine>())
{
string componentdescription = examinecomponents.Examine();
if(!string.IsNullOrEmpty(componentdescription))
{
fullexaminetext.Append(Environment.NewLine + componentdescription);
}
}
//Send to client chat channel
//TODO: Fix fact you can only send to all clients because you cant resolve clients from player entities
IoCManager.Resolve<IChatManager>().DispatchMessage(SS14.Shared.Console.ChatChannel.Visual, fullexaminetext.ToString());
}
}
}

View File

@@ -14,6 +14,7 @@
parent: Clothing
id: ShoesItem
name: Shoes
description: Don't take them off at your office Christmas party
components:
- type: Sprite
texture: Items/shoes.png
@@ -29,6 +30,7 @@
parent: Clothing
id: JanitorUniform
name: Janitor Jumpsuit
description: The jumpsuit for the poor sop with a mop
components:
- type: Sprite
texture: Items/janitorsuit.png
@@ -44,6 +46,7 @@
parent: Clothing
id: SecurityVestClothing
name: Security Vest
description: Bulletproof vest, more or less
components:
- type: Sprite
texture: Clothing/armorvest.png
@@ -57,6 +60,7 @@
parent: Clothing
id: UtilityBeltClothing
name: Utility Belt
description: Belt for holding all your usual tools
components:
- type: Sprite
texture: Clothing/belt_utility.png
@@ -73,6 +77,7 @@
parent: Clothing
id: BackpackClothing
name: Backpack
description: A convenient storage pack
components:
- type: Sprite
texture: Clothing/backpack.png
@@ -88,7 +93,8 @@
- type: entity
parent: Clothing
id: MesonGlasses
name: Mesons
name: Optical Meson Scanners
description: The pinnacle of modern science, wallhacks in real life
components:
- type: Sprite
texture: Clothing/glasses_meson.png
@@ -102,6 +108,7 @@
parent: Clothing
id: YellowGloves
name: Insulated Gloves
description: Electrical gloves that keep you from frying
components:
- type: Sprite
texture: Clothing/gloves_yellow.png
@@ -115,6 +122,7 @@
parent: Clothing
id: HelmetSecurity
name: Security Helmet
description: A slick logo covers the ear: "Concussions are better than holes!"
components:
- type: Sprite
texture: Clothing/helmet_sec.png
@@ -128,6 +136,7 @@
parent: Clothing
id: GasMaskClothing
name: Gas Mask
description: Regulations require these to be stocked after the fourth coolant leak
components:
- type: Sprite
texture: Clothing/gasmask.png
@@ -141,6 +150,7 @@
parent: Clothing
id: IDCardStandard
name: Identification Card
description: A card necessary to access various areas aboard the station
components:
- type: Sprite
texture: Clothing/idcard_standard.png
@@ -154,6 +164,7 @@
parent: Clothing
id: RadioHeadsetEars
name: Headset Radio
description: The radio to keep up to date in real time with fun onboard station activities
components:
- type: Sprite
texture: Clothing/ears_headset.png

View File

@@ -1,6 +1,7 @@
- type: entity
id: DoorContent
name: Actual door
description: It opens, it closes!
components:
- type: Transform
- type: Clickable

View File

@@ -14,6 +14,7 @@
name: "Emergency Toolbox With Handle"
parent: BaseItem
id: RedToolboxItem
description: A shiny red and robust container
components:
- type: Sprite
texture: Items/toolbox_r.png
@@ -28,6 +29,7 @@
name: "Mechanical Toolbox With Handle"
parent: BaseItem
id: BlueToolboxItem
description: A blue box, not the kind you're thinking of
components:
- type: Sprite
texture: Items/toolbox_b.png
@@ -42,6 +44,7 @@
name: "Electrical Toolbox With Handle"
parent: BaseItem
id: YellowToolboxItem
description: A toolbox typically stocked with electrical gear
components:
- type: Sprite
texture: Items/toolbox_y.png
@@ -56,6 +59,7 @@
name: "Extra-Grip™ Mop"
parent: BaseItem
id: MopItem
description: A mop that cant be stopped, viscera cleanup detail awaits
components:
- type: Sprite
texture: Items/mop.png
@@ -69,6 +73,7 @@
name: "Lantern"
parent: BaseItem
id: FlashlightLantern
description: They light the way to freedom
components:
- type: Sprite
texture: Items/Flashlight.png

View File

@@ -2,9 +2,26 @@
name: Urist McHands
id: HumanMob_Content
parent: __engine_human
description: A miserable pile of secrets
components:
- type: Hands
hands:
- left
- right
- type: Inventory
- type: entity
id: MobObserver
name: Observer
save: false
description: Boo!
components:
- type: Transform
- type: Sprite
sprite: Mob/observer.png
scale: 2, 2
drawdepth: MobBase
- type: Icon
icon: Mob/observer.png
- type: Physics
mass: 5

View File

@@ -1,6 +1,7 @@
- type: entity
id: Wire
name: Wire
description: Transfers power, avoid letting things come down it
components:
- type: Transform
- type: Clickable
@@ -20,6 +21,7 @@
parent: Wire
id: BlueWire
name: BlueWire
description: Transfers power, and puts on a good show of it
components:
- type: Sprite
color: Blue
@@ -27,6 +29,7 @@
- type: entity
id: Generator
name: Generator
description: A portal to hell which summons power from the nether
components:
- type: Transform
- type: Clickable
@@ -41,6 +44,7 @@
- type: entity
id: WPPnobattery
name: WPPnobattery
description: Supplies power directly to nearby objects
components:
- type: Transform
- type: Clickable
@@ -58,6 +62,7 @@
parent: WPPnobattery
id: WPP
name: WPP
description: Supplies power at range, has a backup battery just in case
components:
- type: PowerStorage
Capacity: 1000
@@ -69,6 +74,7 @@
- type: entity
id: SMES
name: SMES
description: Stores power in its supermagnetic cells
components:
- type: Transform
- type: Clickable
@@ -88,6 +94,7 @@
- type: entity
id: WiredMachine
name: WiredMachine
description: A monstrosity that does nothing but suck up power from the nearby wires
components:
- type: Transform
- type: Clickable
@@ -105,6 +112,7 @@
- type: entity
id: WirelessMachine
name: WirelessMachine
description: A terrifying monstrosity that sucks up power from the wireless transmitters, Tesla would be proud
components:
- type: Transform
- type: Clickable

View File

@@ -1,6 +1,7 @@
- type: entity
id: ProjectileBullet
name: ProjectileBullet
description: If you can see this you're dead!
components:
- type: Transform
- type: Sprite

View File

@@ -2,6 +2,7 @@
name: Wirecutter
parent: BaseItem
id: Wirecutter
description: This kills the wire.
components:
- type: Wirecutter
- type: Sprite
@@ -14,6 +15,7 @@
name: Screwdriver
parent: BaseItem
id: Screwdriver
description: Industrial grade torque in a small screwdriving package
components:
- type: Screwdriver
- type: Sprite
@@ -26,6 +28,7 @@
name: Welder
parent: BaseItem
id: Welder
description: Melts anything as long as its fueled, don't forget your eye protection
components:
- type: Welder
- type: Sprite
@@ -45,6 +48,7 @@
name: Wrench
parent: BaseItem
id: Wrench
description: A common tool for assembly and disassembly, righty tighty lefty loosey
components:
- type: Wrench
- type: Sprite
@@ -57,6 +61,7 @@
name: Crowbar
parent: BaseItem
id: Crowbar
description: A multipurpose tool to pry open doors and fight interdimensional invaders
components:
- type: Crowbar
- type: Sprite
@@ -69,6 +74,7 @@
name: Multitool
parent: BaseItem
id: Multitool
description: An advanced tool to copy, store, and send electrical pulses and signals through wires and machines
components:
- type: Multitool
- type: Sprite

View File

@@ -2,6 +2,7 @@
name: "LASER"
parent: BaseItem
id: LaserItem
description: A weapon using light amplified by the stimulated emission of radiation
components:
- type: Sprite
texture: Objects/gun.png
@@ -15,6 +16,7 @@
name: GUN
parent: BaseItem
id: GUNITEM
description: A rooty tooty point and shooty
components:
- type: Sprite
texture: Objects/projectileweapon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B