void Start() { if (this.system == null) { this.system = Indexed.GetSingle <IPotentialFieldSystem>(); } this.nodeSources = new PotentialFieldNodeSource[sourceConfigs.Length]; var maxAge = 0; for (int i = 0; i < this.sourceConfigs.Length; i++) { var conf = sourceConfigs[i]; this.nodeSources[i] = this.source.AddNodeSource(conf.sourceKey, conf.layers, conf.potential); this.nodeSources[i].Calculator = conf.calculator as IPotentialCalculator; this.nodeSources[i].Flow = conf.flow; this.nodeSources[i].Enabled = conf.enabled; maxAge = Mathf.Max(conf.age, maxAge); } this.nodeHistory = new IFieldNodeRef[maxAge + 1]; this.Spawned(); }
void Spawned() { if (this.system == null) { this.system = Indexed.GetSingle <IPotentialFieldSystem>(); } }
void Spawned() { if (this.PotentialField == null) { this.PotentialField = Indexed.GetSingle <IPotentialFieldSystem>(); } if (this.navigateOnStart && this.PotentialField != null) { // TODO: Consider moving this into Update() to handle the transform position being set after spawning. this.StartNavigating(); } }
public IList <NodeSample> SampleNodes(IPotentialFieldSystem potentialField, IFieldNodeRef startNode, int layerMask, PotentialFilter filter) { var neighbours = potentialField.GetNeighbours(startNode); neighbours.Insert(0, startNode); var sampleRequest = new SampleRequest(); sampleRequest.potentialLayerMask = layerMask; sampleRequest.filter = filter; sampleRequest.nodes = neighbours; var potentials = potentialField.SamplePotential(sampleRequest); var maxP = potentials[0]; var maxN = 0; for (int i = 1; i < potentials.Count; i++) { var p2 = potentials[i]; if (p2 > maxP) { maxN = i; maxP = p2; } } potentials.ReturnToPool(); var results = ListPool <NodeSample> .Take(); results.Add(new NodeSample(neighbours[maxN], maxP)); neighbours.ReturnToPool(); return(results); }
void Spawned() { this.potentialField = this.componentIndex.GetSingleOrDefault <IPotentialFieldSystem>(); this.isReady = true; }