private void Update() { if (CurrentOrder != null) { if (CurrentOrder.UpdateOrder()) { CurrentOrder.DestroyOrder(); CurrentOrder = null; } } if (Time.time >= nextStateUpdateTime) { nextStateUpdateTime += stateUpdateTime; if (aiAttributes.AttachedSensors.EnemyMilitaryNearby) { if (CurrentOrder != null) { CurrentOrder.DestroyOrder(); } CurrentOrder = gameObject.AddComponent <FleeOrder>(); } else if (aiAttributes.AttachedSensors.EnemyNearby) { if (CurrentOrder != null) { CurrentOrder.DestroyOrder(); } CurrentOrder = gameObject.AddComponent <AttackOrder>(); } else if (CurrentOrder == null && RelationshipManager.IsFactionInWar(tag)) { CurrentOrder = gameObject.AddComponent <RaiderHuntOrder>(); } else if (CurrentOrder == null && !RelationshipManager.IsFactionInWar(tag)) { CurrentOrder = gameObject.AddComponent <PatrolShipsOrder>(); } } }
private void Update() { if (CurrentOrder != null) { if (CurrentOrder.UpdateOrder()) { CurrentOrder.DestroyOrder(); CurrentOrder = null; } } if (Time.time >= nextStateUpdateTime) { nextStateUpdateTime += stateUpdateTime; if (automate) { if (CurrentOrder == null && RelationshipManager.IsFactionInWar(tag)) { CurrentOrder = gameObject.AddComponent <RaiderHuntOrder>(); } else if (CurrentOrder == null && !RelationshipManager.IsFactionInWar(tag)) { CurrentOrder = gameObject.AddComponent <PatrolBuildingsOrder>(); } } if (attackOnSight) { if (aiAttributes.AttachedSensors.EnemyNearby && (CurrentOrder == null || CurrentOrder.GetType() != typeof(ManualMoveOrder))) { if (CurrentOrder != null) { CurrentOrder.DestroyOrder(); } CurrentOrder = gameObject.AddComponent <AttackOrder>(); } } } }