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
|
|
@ -1,7 +1,30 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public abstract class AgentBehavior
|
||||
{
|
||||
public abstract void Update(float delta);
|
||||
|
||||
protected float ThrustInput(float2 deltaV) =>
|
||||
saturate( // Input must be normalized
|
||||
pow( // Apply specificity as exponent to dot product to control how specific the direction needs to be
|
||||
saturate( // Discard negative dot product (we're facing away from desired direction)
|
||||
dot(normalize(Entity.Direction), normalize(deltaV))), // Cosine of angle between direction and deltaV
|
||||
ControllerData.ThrustSpecificity)
|
||||
* length(deltaV) * ControllerData.ThrustSensitivity);
|
||||
|
||||
protected float TurningInput(float2 deltaV) => clamp(-Entity.Direction.AngleDiff(deltaV) * ControllerData.TurningSensitivity, -1, 1);
|
||||
|
||||
protected ControllerData ControllerData;
|
||||
protected GameContext Context;
|
||||
protected Entity Entity;
|
||||
|
||||
public AgentBehavior(GameContext context, Entity entity, ControllerData controllerData)
|
||||
{
|
||||
Context = context;
|
||||
Entity = entity;
|
||||
ControllerData = controllerData;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue