moths can eat goat wool (#21704)
* add Wooly system * add RequireDead to Food * minor fix+cleanup and fix repeating * minor fix+cleanup and fix repeating * make goat wooly --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -96,7 +96,7 @@ public sealed class FoodSystem : EntitySystem
|
||||
public (bool Success, bool Handled) TryFeed(EntityUid user, EntityUid target, EntityUid food, FoodComponent foodComp)
|
||||
{
|
||||
//Suppresses eating yourself and alive mobs
|
||||
if (food == user || _mobState.IsAlive(food))
|
||||
if (food == user || (_mobState.IsAlive(food) && foodComp.RequireDead))
|
||||
return (false, false);
|
||||
|
||||
// Target can't be fed or they're already eating
|
||||
@@ -304,33 +304,38 @@ public sealed class FoodSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
// don't try to repeat if its being deleted
|
||||
args.Repeat = false;
|
||||
DeleteAndSpawnTrash(component, uid, args.User);
|
||||
}
|
||||
|
||||
public void DeleteAndSpawnTrash(FoodComponent component, EntityUid food, EntityUid user)
|
||||
{
|
||||
var ev = new BeforeFullyEatenEvent
|
||||
{
|
||||
User = args.User
|
||||
User = user
|
||||
};
|
||||
RaiseLocalEvent(uid, ev);
|
||||
RaiseLocalEvent(food, ev);
|
||||
if (ev.Cancelled)
|
||||
return;
|
||||
|
||||
if (string.IsNullOrEmpty(component.Trash))
|
||||
QueueDel(uid);
|
||||
else
|
||||
DeleteAndSpawnTrash(component, uid, args.User);
|
||||
}
|
||||
{
|
||||
QueueDel(food);
|
||||
return;
|
||||
}
|
||||
|
||||
public void DeleteAndSpawnTrash(FoodComponent component, EntityUid food, EntityUid? user = null)
|
||||
{
|
||||
//We're empty. Become trash.
|
||||
var position = Transform(food).MapPosition;
|
||||
var finisher = Spawn(component.Trash, position);
|
||||
|
||||
// If the user is holding the item
|
||||
if (user != null && _hands.IsHolding(user.Value, food, out var hand))
|
||||
if (_hands.IsHolding(user, food, out var hand))
|
||||
{
|
||||
Del(food);
|
||||
|
||||
// Put the trash in the user's hand
|
||||
_hands.TryPickup(user.Value, finisher, hand);
|
||||
_hands.TryPickup(user, finisher, hand);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -347,7 +352,7 @@ public sealed class FoodSystem : EntitySystem
|
||||
return;
|
||||
|
||||
// have to kill mouse before eating it
|
||||
if (_mobState.IsAlive(uid))
|
||||
if (_mobState.IsAlive(uid) && component.RequireDead)
|
||||
return;
|
||||
|
||||
// only give moths eat verb for clothes since it would just fail otherwise
|
||||
|
||||
Reference in New Issue
Block a user