public virtual void InitializeAI() { T entity = GetEntity(); entity.HasBrain = true; Navigator = GetComponent <BaseNavigator>(); if (UseAIDesign) { AIDesign = new AIDesign(); AIDesign.SetAvailableStates(GetStateList()); if (Events == null) { Events = new AIEvents(); } bool senseFriendlies = MaxGroupSize > 0; Senses.Init(entity, SenseRange, TargetLostRange, VisionCone, CheckVisionCone, CheckLOS, IgnoreNonVisionSneakers, ListenRange, HostileTargetsOnly, senseFriendlies, IgnoreSafeZonePlayers, SenseTypes); if (DefaultDesignSO == null) { Debug.LogWarning("Brain on " + base.gameObject.name + " is trying to load a null AI design!"); return; } Events.Memory.Position.Set(base.transform.position, 4); LoadAIDesign(AIDesigns.GetByNameOrInstance(DefaultDesignSO.Filename, InstanceSpecificDesign), null); AIInformationZone forPoint = AIInformationZone.GetForPoint(base.transform.position, false); if (forPoint != null) { forPoint.RegisterSleepableEntity(this); } } BaseEntity.Query.Server.AddBrain(entity); StartMovementTick(); }
// AIStateEvent: triggers all AI to a new event public void AIStateEvent(AIEvents aiEvent) { foreach (Enemy enemy in enemies) { switch (aiEvent) { case AIEvents.PlayerOnNewTile: enemy.stateClass.playerOnNewTile(); break; case AIEvents.OnMetalCubeRust: enemy.stateClass.onMetalCubeRust(); break; default: Debug.Log("AIManager.cs: undefined AIEvent!!"); break; } } }