public void Init(int seed) { FixedUpdateManager = SimulatorManager.Instance.FixedUpdateManager; NPCManager = SimulatorManager.Instance.NPCManager; RandomGenerator = new System.Random(seed); _seed = seed; SetNeededComponents(); ResetData(); if (_ActiveBehaviour) { _ActiveBehaviour.controller = this; _ActiveBehaviour.rb = rb; _ActiveBehaviour.Init(seed); } }
public T SetBehaviour <T>() where T : NPCBehaviourBase { if (ActiveBehaviour as T != null) { return(_ActiveBehaviour as T); } if (_ActiveBehaviour != null) { Destroy(_ActiveBehaviour); _ActiveBehaviour = null; } T behaviour = gameObject.AddComponent <T>(); _ActiveBehaviour = behaviour; _ActiveBehaviour.controller = this; _ActiveBehaviour.rb = rb; _ActiveBehaviour.Init(_seed); return(behaviour); }
internal NPCBehaviourBase SetBehaviour(Type t) { if (ActiveBehaviour != null && ActiveBehaviour.GetType().IsAssignableFrom(t)) { return(_ActiveBehaviour); } if (_ActiveBehaviour != null) { Destroy(_ActiveBehaviour); _ActiveBehaviour = null; } NPCBehaviourBase behaviour = (NPCBehaviourBase)gameObject.AddComponent(t); _ActiveBehaviour = behaviour; _ActiveBehaviour.controller = this; _ActiveBehaviour.rb = rb; _ActiveBehaviour.Init(_seed); return(behaviour); }