Pneumatic cannons (#4560)
* basics & visuals * pneumatic cannon works perf * loc + popups * gas tank does stuff + queue changes * updates * b * forcefeeding * inhand * crafting! * pie cannon now is a pneumatic cannon * oopy * fix for entman + verbs * pie * change for tools * actual * combat mode + better sounds * reviews
This commit is contained in:
@@ -199,7 +199,7 @@ namespace Content.Server.Nutrition.Components
|
||||
|
||||
if (string.IsNullOrEmpty(TrashPrototype))
|
||||
{
|
||||
Owner.Delete();
|
||||
Owner.QueueDelete();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -208,8 +208,6 @@ namespace Content.Server.Nutrition.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void DeleteAndSpawnTrash(IEntity user)
|
||||
{
|
||||
//We're empty. Become trash.
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using Content.Server.Nutrition.EntitySystems;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Nutrition.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// A food item with this component will be forcefully fed to anyone
|
||||
/// </summary>
|
||||
[RegisterComponent, Friend(typeof(ForcefeedOnCollideSystem))]
|
||||
public class ForcefeedOnCollideComponent : Component
|
||||
{
|
||||
public override string Name => "ForcefeedOnCollide";
|
||||
|
||||
/// <summary>
|
||||
/// Since this component is primarily used by the pneumatic cannon, which adds this comp on throw start
|
||||
/// and wants to remove it on throw end, this is set to false. However, you're free to change it if you want
|
||||
/// something that can -always- be forcefed on collide, or something.
|
||||
/// </summary>
|
||||
[DataField("removeOnThrowEnd")]
|
||||
public bool RemoveOnThrowEnd = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Content.Server.Nutrition.Components;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Nutrition.EntitySystems
|
||||
{
|
||||
public class ForcefeedOnCollideSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ForcefeedOnCollideComponent, ThrowDoHitEvent>(OnThrowDoHit);
|
||||
SubscribeLocalEvent<ForcefeedOnCollideComponent, LandEvent>(OnLand);
|
||||
}
|
||||
|
||||
private void OnThrowDoHit(EntityUid uid, ForcefeedOnCollideComponent component, ThrowDoHitEvent args)
|
||||
{
|
||||
if (!args.Target.HasComponent<HungerComponent>())
|
||||
return;
|
||||
if (!EntityManager.TryGetComponent<FoodComponent>(uid, out var food))
|
||||
return;
|
||||
|
||||
// the 'target' isnt really the 'user' per se.. but..
|
||||
food.TryUseFood(args.Target, args.Target);
|
||||
}
|
||||
|
||||
private void OnLand(EntityUid uid, ForcefeedOnCollideComponent component, LandEvent args)
|
||||
{
|
||||
if (!component.RemoveOnThrowEnd)
|
||||
return;
|
||||
|
||||
EntityManager.RemoveComponent(uid, component);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user