public void Init(EntityState aEntityState) { this.id = aEntityState.id; this.transform.position = Util.V2IOffsetV3(aEntityState.pos, aEntityState.size, aEntityState.isFront); this.name = aEntityState.name; foreach (Node node in aEntityState.GetNodes()) { if (!node.hasUp) { continue; } Vector3 currentPosition = Util.V2IOffsetV3(node.absolutePos, new Vector2Int(1, 1)); float studX = currentPosition.x; float studY = currentPosition.y + (Constants.BLOCKHEIGHT / 2); GameObject stud = Instantiate(GM.instance.studPrefab, new Vector3(studX, studY, 0), Quaternion.identity); stud.transform.SetParent(this.model.transform, true); Renderer studRenderer = stud.GetComponent <Renderer>(); studRenderer.material.color = aEntityState.defaultColor; this.childRenderers.Add(studRenderer); } SetColor(aEntityState.defaultColor); this.oldEntityState = aEntityState; this.recievesUpdates = true; this.entityBrain = new EntityBrain(this); }
void ChangeAction(ActionResult aActionResult) { Debug.Assert(aActionResult.entityAction.id == this.id); // Debug.Log(this.id + " ChangeActionExternally requiredActionResult queue size: " + aActionResult.requiredActionResultTree.Count); foreach (ActionResult requiredActionResult in aActionResult.requiredActionResultTree) { EntityBrain otherEntityBrain = requiredActionResult.entityAction.entityBrain; otherEntityBrain.ChangeAction(requiredActionResult); } this.needsNewAction = false; if (!(aActionResult.entityAction is WaitAction)) { Debug.Log(this.id + " ChangeAction performing " + aActionResult.entityAction.GetType()); } this.stateMachine.ChangeState(aActionResult.entityAction); }
// EntityAction should require a constructor with at least the id of the entity // this constructor should set // this.entityActionEnum // this.priorityList // this.id // this.direction // this.entityBrain // this.entityBase protected EntityAction(int aId, EntityActionEnum aEntityActionEnum, Vector2Int?aDirection = null, List <EntityActionEnum> aPriorityList = null) { this.entityActionEnum = aEntityActionEnum; this.priorityList = aPriorityList ?? new List <EntityActionEnum>(); this.id = aId; this.direction = aDirection ?? Vector2Int.zero; this.entityBase = GM.boardManager.GetEntityBaseById(this.id); this.entityBrain = this.entityBase.entityBrain; switch (this.entityActionEnum) { case EntityActionEnum.MOVE: this.canBeInterrupted = true; break; case EntityActionEnum.FALL: this.canBeInterrupted = true; break; case EntityActionEnum.DIE: this.canBeInterrupted = false; break; case EntityActionEnum.PUSH: this.canBeInterrupted = true; break; case EntityActionEnum.TURN: this.canBeInterrupted = true; break; case EntityActionEnum.WAIT: this.canBeInterrupted = true; break; case EntityActionEnum.EXIT: this.canBeInterrupted = false; break; default: throw new ArgumentOutOfRangeException(); } }
public ColonizeState(EntityBrain brain, Vector3Int location) : base(brain, location) { }
public void AddShip(EntityBrain brain) { Ships.Add(brain); brain.fleet = this; }
// Use this for initialization void Start() { CoolDown = 0; EntityBrain = GetComponent <EntityBrain>(); StarSystem.TimeController.TimeObjects.Add(this); }
public MoveState(EntityBrain brain, Vector3Int target) : base(brain) { Target = target; }
public GuardState(EntityBrain brain) : base(brain) { }
public BaseState(EntityBrain brain) { Brain = brain; }