public bool RemoveResourcesWithToss(ResourceAmount resources, Vector3 position, Zone Zone) // Todo: Kill this one. { if (!Zone.Resources.HasResource(resources)) { return(false); } if (!(Zone is Stockpile)) { return(false); } var stock = Zone as Stockpile; // Todo: Stockpile deals with it's own boxes. var resourceType = Library.GetResourceType(resources.Type); var num = stock.Resources.RemoveMaxResources(resources, resources.Count); stock.HandleBoxes(); foreach (var tag in resourceType.Tags) { if (PersistentData.CachedResourceTagCounts.ContainsKey(tag)) // Move cache into worldmanager... { PersistentData.CachedResourceTagCounts[tag] -= num; Trace.Assert(PersistentData.CachedResourceTagCounts[tag] >= 0); } } for (int i = 0; i < num; i++) { // Make a toss from the last crate to the agent. var startPosition = stock.Voxels.Count > 0 ? stock.Voxels.First().Center + new Vector3(0.0f, 1.0f, 0.0f) : Vector3.Zero; if (stock.Boxes.Count > 0) { startPosition = stock.Boxes.Last().Position + MathFunctions.RandVector3Cube() * 0.5f; } GameComponent newEntity = EntityFactory.CreateEntity <GameComponent>(resources.Type + " Resource", startPosition); TossMotion toss = new TossMotion(1.0f + MathFunctions.Rand(0.1f, 0.2f), 2.5f + MathFunctions.Rand(-0.5f, 0.5f), newEntity.LocalTransform, position); if (newEntity.GetRoot().GetComponent <Physics>().HasValue(out var newPhysics)) { newPhysics.CollideMode = Physics.CollisionMode.None; } newEntity.AnimationQueue.Add(toss); toss.OnComplete += () => newEntity.Die(); } RecomputeCachedVoxelstate(); return(true); }
private float dist(Zone zone) { return((zone.GetBoundingBox().Center() - Creature.AI.Position).LengthSquared()); }
public void SetZone(Zone pile) { Agent.Blackboard.SetData(StockpileName, pile); }