// Start is called before the first frame update void Start() { rb = GetComponent <Rigidbody>(); PopulationBehavior popBehavior = population.GetComponent <PopulationBehavior>(); boids = popBehavior.boids; }
public void OnBehaviorComplete(GameObject animal) { if (!animalsToExecutionData.ContainsKey(animal))// Discriminate force exited callbacks from removing animals { return; } PopulationBehavior behavior = animalsToExecutionData[animal].NextBehavior(defaultBehaviors); if (behavior == null) { return; } behavior.EnterBehavior(animal); }
public List <GameObject> GetVisibleBoids() { PopulationBehavior popBehavior = population.GetComponent <PopulationBehavior>(); boids = popBehavior.boids; List <GameObject> ans = new List <GameObject>(); foreach (GameObject boid in boids) { if (IsVisible(boid)) { ans.Add(boid); } } return(ans); }
// TODO determine better way to setup behaviors private List <PopulationBehavior> CopyBehaviors() { List <PopulationBehavior> copiedBehaviors = new List <PopulationBehavior>(); // Have to copy behavior scriptable objects for them to work on multiple populations foreach (PopulationBehavior behavior in GenericBehaviors) { List <BehaviorPattern> patterns = new List <BehaviorPattern>(); foreach (BehaviorPattern pattern in behavior.behaviorPatterns) { patterns.Add(Instantiate(pattern, BehaviorPatternUpdater.gameObject.transform)); } PopulationBehavior newBehavior = Instantiate(behavior); newBehavior.behaviorPatterns = patterns; copiedBehaviors.Add(newBehavior); } return(copiedBehaviors); }