From 1e8efb1dd55bc60332c07ae4c63f7b69683a750e Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Sun, 17 Jul 2022 23:48:36 -0400 Subject: [PATCH] Port cleanbots from Nyano (#9853) --- .../AI/EntitySystems/GoToPuddleSystem.cs | 20 +++++++ .../Utility/Actions/Bots/GoToPuddleAndWait.cs | 50 ++++++++++++++++++ .../Bots/BufferNearbyPuddlesExp.cs | 40 ++++++++++++++ .../Prototypes/Entities/Mobs/NPCs/silicon.yml | 28 ++++++++++ Resources/Prototypes/NPCs/behavior_sets.yml | 8 ++- .../Recipes/Crafting/Graphs/bots/cleanbot.yml | 27 ++++++++++ .../Prototypes/Recipes/Crafting/bots.yml | 13 +++++ .../Silicon/Bots/cleanbot.rsi/cleanbot.png | Bin 0 -> 645 bytes .../Mobs/Silicon/Bots/cleanbot.rsi/meta.json | 20 +++++++ 9 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 Content.Server/AI/EntitySystems/GoToPuddleSystem.cs create mode 100644 Content.Server/AI/Utility/Actions/Bots/GoToPuddleAndWait.cs create mode 100644 Content.Server/AI/Utility/ExpendableActions/Bots/BufferNearbyPuddlesExp.cs create mode 100644 Resources/Prototypes/Recipes/Crafting/Graphs/bots/cleanbot.yml create mode 100644 Resources/Textures/Mobs/Silicon/Bots/cleanbot.rsi/cleanbot.png create mode 100644 Resources/Textures/Mobs/Silicon/Bots/cleanbot.rsi/meta.json diff --git a/Content.Server/AI/EntitySystems/GoToPuddleSystem.cs b/Content.Server/AI/EntitySystems/GoToPuddleSystem.cs new file mode 100644 index 0000000000..c9816aba27 --- /dev/null +++ b/Content.Server/AI/EntitySystems/GoToPuddleSystem.cs @@ -0,0 +1,20 @@ +using Content.Server.Fluids.Components; + +namespace Content.Server.AI.EntitySystems +{ + public sealed class GoToPuddleSystem : EntitySystem + { + [Dependency] private readonly EntityLookupSystem _lookup = default!; + + public EntityUid GetNearbyPuddle(EntityUid cleanbot, float range = 10) + { + foreach (var entity in _lookup.GetEntitiesInRange(cleanbot, range)) + { + if (HasComp(entity)) + return entity; + } + + return default; + } + } +} diff --git a/Content.Server/AI/Utility/Actions/Bots/GoToPuddleAndWait.cs b/Content.Server/AI/Utility/Actions/Bots/GoToPuddleAndWait.cs new file mode 100644 index 0000000000..d9dff3f0e5 --- /dev/null +++ b/Content.Server/AI/Utility/Actions/Bots/GoToPuddleAndWait.cs @@ -0,0 +1,50 @@ +using Content.Server.AI.Operators; +using Content.Server.AI.Operators.Generic; +using Content.Server.AI.Operators.Movement; +using Content.Server.AI.WorldState; +using Content.Server.AI.Utility.Considerations.Containers; +using Content.Server.AI.Utility.Considerations; +using Content.Server.AI.Utility.Considerations.ActionBlocker; +using Content.Server.AI.WorldState.States.Movement; +using Content.Server.AI.WorldState.States; + +namespace Content.Server.AI.Utility.Actions.Bots +{ + public sealed class GoToPuddleAndWait : UtilityAction + { + public EntityUid Target { get; set; } = default!; + + public override void SetupOperators(Blackboard context) + { + MoveToEntityOperator moveOperator = new MoveToEntityOperator(Owner, Target, 0, 0); + float waitTime = 3f; + + ActionOperators = new Queue(new AiOperator[] + { + moveOperator, + new WaitOperator(waitTime), + }); + } + + protected override void UpdateBlackboard(Blackboard context) + { + base.UpdateBlackboard(context); + context.GetState().SetValue(Target); + context.GetState().SetValue(Target); + // Can just set ourselves as entity given unarmed just inherits from meleeweapon + } + + protected override IReadOnlyCollection> GetConsiderations(Blackboard context) + { + var considerationsManager = IoCManager.Resolve(); + + return new[] + { + considerationsManager.Get() + .BoolCurve(context), + considerationsManager.Get() + .BoolCurve(context), + }; + } + } +} diff --git a/Content.Server/AI/Utility/ExpendableActions/Bots/BufferNearbyPuddlesExp.cs b/Content.Server/AI/Utility/ExpendableActions/Bots/BufferNearbyPuddlesExp.cs new file mode 100644 index 0000000000..d3cff226ec --- /dev/null +++ b/Content.Server/AI/Utility/ExpendableActions/Bots/BufferNearbyPuddlesExp.cs @@ -0,0 +1,40 @@ +using Content.Server.AI.Components; +using Content.Server.AI.EntitySystems; +using Content.Server.AI.Utility.Actions; +using Content.Server.AI.Utility.Actions.Bots; +using Content.Server.AI.Utility.Considerations; +using Content.Server.AI.Utility.Considerations.Combat.Melee; +using Content.Server.AI.WorldState; +using Content.Server.AI.WorldState.States; +using Content.Server.AI.Utility.Considerations.ActionBlocker; + + + +namespace Content.Server.AI.Utility.ExpandableActions.Bots +{ + public sealed class BufferNearbyPuddlesExp : ExpandableUtilityAction + { + public override float Bonus => 30; + + protected override IReadOnlyCollection> GetCommonConsiderations(Blackboard context) + { + var considerationsManager = IoCManager.Resolve(); + + return new[] + { + considerationsManager.Get() + .BoolCurve(context), + }; + } + public override IEnumerable GetActions(Blackboard context) + { + var owner = context.GetState().GetValue(); + if (!IoCManager.Resolve().TryGetComponent(owner, out AiControllerComponent? controller)) + { + throw new InvalidOperationException(); + } + + yield return new GoToPuddleAndWait() {Owner = owner, Target = EntitySystem.Get().GetNearbyPuddle(Owner), Bonus = Bonus}; + } + } +} diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml b/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml index c815ea8c96..b7fd334b12 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/silicon.yml @@ -128,3 +128,31 @@ makeSentient: true name: honkbot description: An artificial being of pure evil. + +- type: entity + parent: MobSiliconBase + id: MobCleanBot + name: cleanbot + description: The creep of automation now threatening space janitors. + components: + - type: Sprite + drawdepth: Mobs + sprite: Mobs/Silicon/Bots/cleanbot.rsi + state: cleanbot + - type: UtilityAI + behaviorSets: + - CleanBot + - type: Drain + range: 1 + unitsDestroyedPerSecond: 6 + - type: Construction + graph: CleanBot + node: bot + - type: SentienceTarget + flavorKind: mechanical + - type: SolutionContainerManager + solutions: + drainBuffer: + maxVol: 30 + - type: DrainableSolution + solution: drainBuffer diff --git a/Resources/Prototypes/NPCs/behavior_sets.yml b/Resources/Prototypes/NPCs/behavior_sets.yml index 481df2f256..a930c4b2fb 100644 --- a/Resources/Prototypes/NPCs/behavior_sets.yml +++ b/Resources/Prototypes/NPCs/behavior_sets.yml @@ -27,6 +27,12 @@ actions: - MoveRightAndLeftTen +- type: behaviorSet + id: CleanBot + actions: + - BufferNearbyPuddlesExp + - WanderAndWait + - type: behaviorSet id: Spirate actions: @@ -43,4 +49,4 @@ - type: behaviorSet id: UnarmedAttackHostiles actions: - - UnarmedAttackNearbyHostilesExp \ No newline at end of file + - UnarmedAttackNearbyHostilesExp diff --git a/Resources/Prototypes/Recipes/Crafting/Graphs/bots/cleanbot.yml b/Resources/Prototypes/Recipes/Crafting/Graphs/bots/cleanbot.yml new file mode 100644 index 0000000000..18282891a0 --- /dev/null +++ b/Resources/Prototypes/Recipes/Crafting/Graphs/bots/cleanbot.yml @@ -0,0 +1,27 @@ +- type: constructionGraph + id: CleanBot + start: start + graph: + - node: start + edges: + - to: bot + steps: + - prototype: Bucket + icon: + sprite: Objects/Tools/bucket.rsi + state: icon + name: bucket + - prototype: ProximitySensor + icon: + sprite: Objects/Misc/proximity_sensor.rsi + state: icon + name: promixmity sensor + doAfter: 2 + - tag: BorgArm + icon: + sprite: Mobs/Silicon/drone.rsi + state: l_hand + name: borg arm + doAfter: 2 + - node: bot + entity: MobCleanBot diff --git a/Resources/Prototypes/Recipes/Crafting/bots.yml b/Resources/Prototypes/Recipes/Crafting/bots.yml index 24d70aa503..e6abeaa012 100644 --- a/Resources/Prototypes/Recipes/Crafting/bots.yml +++ b/Resources/Prototypes/Recipes/Crafting/bots.yml @@ -1,3 +1,16 @@ +- type: construction + name: cleanbot + id: cleanbot + graph: CleanBot + startNode: start + targetNode: bot + category: Utilities + objectType: Item + description: This bot wanders around the station, mopping up any puddles it sees. + icon: + sprite: Mobs/Silicon/Bots/cleanbot.rsi + state: cleanbot + - type: construction name: honkbot id: honkbot diff --git a/Resources/Textures/Mobs/Silicon/Bots/cleanbot.rsi/cleanbot.png b/Resources/Textures/Mobs/Silicon/Bots/cleanbot.rsi/cleanbot.png new file mode 100644 index 0000000000000000000000000000000000000000..e64cae9af23e9beac08461b50db6862406474b07 GIT binary patch literal 645 zcmV;00($+4P)B!qHYpMjf(;F|T%g$0648)TkVAvy zAg%ocwYC`!4NgG{NrSUj&<)YhP+&q~wB6895EQ)nY43dRyr*|ZrwQ*n_}=~Qyzl4z z?k(@@hXG3hNB{{S0VIF~7!CkMQHZ8#KC64lWRjR`#bVL&SyupPE`mUFD>G5uF#t73 zW1O=P-Au4<7eWZYnwud)p%B=S9SBPRvpE%Br*|?$9nZj2a0V&|rvwDrue`(a;{&93 zrbzxMCxj4oK(y)bWr4&f(SPP!CFrSqHRrqocH|F4xa;Yc0z3s%T_2BFV*A+BF zQ#AjGk2o^#3P6SCI5zGJMoq6CA_NI2+Z+Vfe(jh(=MI1xqc&F>5RRrgR?o`m%6kHs z&DjnZru9p1GqUyY;wpB)9l%SyM9`2mURo=2tDhq`5Se^~Gp*K~-}x4ddMpxw+Vu(8 zQO^#vjLRK$RaKk&K>r!lR)zTm@_XMMK>J&lp_@b|cFlzV{gecd01`j~NB{{S0fqxW z<^wVxppy9j_s9R14`}lmD7P?}d;rZ+O^B*T`2ZeLQRXuunkhyH6z}o@JgBx*w#*02 zEC17c0MijXC7V~z%CmfcnzuT@A67lf2d>W7NjSR9g%aj;q;L6vD3