Port cleanbots from Nyano (#9853)
This commit is contained in:
20
Content.Server/AI/EntitySystems/GoToPuddleSystem.cs
Normal file
20
Content.Server/AI/EntitySystems/GoToPuddleSystem.cs
Normal file
@@ -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<PuddleComponent>(entity))
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
50
Content.Server/AI/Utility/Actions/Bots/GoToPuddleAndWait.cs
Normal file
50
Content.Server/AI/Utility/Actions/Bots/GoToPuddleAndWait.cs
Normal file
@@ -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<AiOperator>(new AiOperator[]
|
||||||
|
{
|
||||||
|
moveOperator,
|
||||||
|
new WaitOperator(waitTime),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void UpdateBlackboard(Blackboard context)
|
||||||
|
{
|
||||||
|
base.UpdateBlackboard(context);
|
||||||
|
context.GetState<TargetEntityState>().SetValue(Target);
|
||||||
|
context.GetState<MoveTargetState>().SetValue(Target);
|
||||||
|
// Can just set ourselves as entity given unarmed just inherits from meleeweapon
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
|
||||||
|
{
|
||||||
|
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();
|
||||||
|
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
considerationsManager.Get<CanMoveCon>()
|
||||||
|
.BoolCurve(context),
|
||||||
|
considerationsManager.Get<TargetAccessibleCon>()
|
||||||
|
.BoolCurve(context),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<Func<float>> GetCommonConsiderations(Blackboard context)
|
||||||
|
{
|
||||||
|
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();
|
||||||
|
|
||||||
|
return new[]
|
||||||
|
{
|
||||||
|
considerationsManager.Get<CanMoveCon>()
|
||||||
|
.BoolCurve(context),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public override IEnumerable<UtilityAction> GetActions(Blackboard context)
|
||||||
|
{
|
||||||
|
var owner = context.GetState<SelfState>().GetValue();
|
||||||
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out AiControllerComponent? controller))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new GoToPuddleAndWait() {Owner = owner, Target = EntitySystem.Get<GoToPuddleSystem>().GetNearbyPuddle(Owner), Bonus = Bonus};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -128,3 +128,31 @@
|
|||||||
makeSentient: true
|
makeSentient: true
|
||||||
name: honkbot
|
name: honkbot
|
||||||
description: An artificial being of pure evil.
|
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
|
||||||
|
|||||||
@@ -27,6 +27,12 @@
|
|||||||
actions:
|
actions:
|
||||||
- MoveRightAndLeftTen
|
- MoveRightAndLeftTen
|
||||||
|
|
||||||
|
- type: behaviorSet
|
||||||
|
id: CleanBot
|
||||||
|
actions:
|
||||||
|
- BufferNearbyPuddlesExp
|
||||||
|
- WanderAndWait
|
||||||
|
|
||||||
- type: behaviorSet
|
- type: behaviorSet
|
||||||
id: Spirate
|
id: Spirate
|
||||||
actions:
|
actions:
|
||||||
@@ -43,4 +49,4 @@
|
|||||||
- type: behaviorSet
|
- type: behaviorSet
|
||||||
id: UnarmedAttackHostiles
|
id: UnarmedAttackHostiles
|
||||||
actions:
|
actions:
|
||||||
- UnarmedAttackNearbyHostilesExp
|
- UnarmedAttackNearbyHostilesExp
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
- type: construction
|
||||||
name: honkbot
|
name: honkbot
|
||||||
id: honkbot
|
id: honkbot
|
||||||
|
|||||||
BIN
Resources/Textures/Mobs/Silicon/Bots/cleanbot.rsi/cleanbot.png
Normal file
BIN
Resources/Textures/Mobs/Silicon/Bots/cleanbot.rsi/cleanbot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 645 B |
20
Resources/Textures/Mobs/Silicon/Bots/cleanbot.rsi/meta.json
Normal file
20
Resources/Textures/Mobs/Silicon/Bots/cleanbot.rsi/meta.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"size": {
|
||||||
|
"x": 32,
|
||||||
|
"y": 32
|
||||||
|
},
|
||||||
|
"license": "CC-BY-SA-3.0",
|
||||||
|
"copyright": "Taken from https://github.com/tgstation/tgstation/commit/53d1f1477d22a11a99c6c6924977cd431075761b",
|
||||||
|
"states": [
|
||||||
|
{
|
||||||
|
"name": "cleanbot",
|
||||||
|
"delays": [
|
||||||
|
[
|
||||||
|
0.5,
|
||||||
|
0.2
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user