Control Modules & Job System
Agent behaviors are no longer hard coded but instead created by equippable control modules Game Context has a job system which assigns appropriate tasks to drone control modules
This commit is contained in:
parent
6aeb2ae280
commit
ab8aa5fb9a
27 changed files with 480 additions and 190 deletions
69
Assets/Scripts/ServerShared/Behaviors/TowingController.cs
Normal file
69
Assets/Scripts/ServerShared/Behaviors/TowingController.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
[MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship)]
|
||||
public class TowingControllerData : ControllerData
|
||||
{
|
||||
public override IBehavior CreateInstance(GameContext context, Entity entity, Gear item)
|
||||
{
|
||||
return new TowingController(context, this, entity, item);
|
||||
}
|
||||
}
|
||||
|
||||
public class TowingController : IBehavior, IPersistentBehavior, IController
|
||||
{
|
||||
public TaskType JobType => TaskType.Tow;
|
||||
public bool Available => _towingTask != Guid.Empty;
|
||||
public BehaviorData Data => _data;
|
||||
|
||||
private TowingControllerData _data;
|
||||
private GameContext _context;
|
||||
private Entity _entity;
|
||||
private Gear _item;
|
||||
private Guid _towingTask;
|
||||
|
||||
public TowingController(GameContext context, TowingControllerData data, Entity entity, Gear item)
|
||||
{
|
||||
_context = context;
|
||||
_data = data;
|
||||
_entity = entity;
|
||||
_item = item;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Update(float delta)
|
||||
{
|
||||
}
|
||||
|
||||
public PersistentBehaviorData Store()
|
||||
{
|
||||
return new TowingControllerPersistence
|
||||
{
|
||||
TowingTask = _towingTask
|
||||
};
|
||||
}
|
||||
|
||||
public void Restore(PersistentBehaviorData data)
|
||||
{
|
||||
var towingControllerPersistence = data as TowingControllerPersistence;
|
||||
_towingTask = towingControllerPersistence.TowingTask;
|
||||
}
|
||||
|
||||
public void AssignTask(Guid task)
|
||||
{
|
||||
_towingTask = task;
|
||||
}
|
||||
}
|
||||
|
||||
public class TowingControllerPersistence : PersistentBehaviorData
|
||||
{
|
||||
[JsonProperty("towingTask"), Key(0)]
|
||||
public Guid TowingTask;
|
||||
}
|
||||
Loading…
Reference in a new issue