internal override List <GameObject> Execute(BehaviorUpdateContext context) { var debrisObject = context.GameContext.GameObjects.Add("GenericDebris", context.GameObject.Owner); debrisObject.Transform.Translation = context.GameObject.Transform.Translation + Offset; debrisObject.Transform.Rotation = context.GameObject.Transform.Rotation; // Model var w3dDebrisDraw = (W3dDebrisDraw)debrisObject.DrawModules[0]; // TODO //var modelName = ModelNames[context.GameContext.Random.Next(ModelNames.Length)]; var modelName = ModelNames[0]; w3dDebrisDraw.SetModelName(modelName); // Physics var physicsBehavior = debrisObject.FindBehavior <PhysicsBehavior>(); physicsBehavior.Mass = Mass; if (Disposition.Get(ObjectDisposition.SendItFlying)) { physicsBehavior.AddForce( new Vector3( ((float)context.GameContext.Random.NextDouble() - 0.5f) * DispositionIntensity * 200, ((float)context.GameContext.Random.NextDouble() - 0.5f) * DispositionIntensity * 200, DispositionIntensity * 200)); } // TODO: Count, Disposition, DispositionIntensity return(new List <GameObject> { debrisObject }); }
internal override List <GameObject> Execute(BehaviorUpdateContext context, Vector3?position) { // TODO: Cache this. var debrisObjectDefinition = context.GameContext.AssetLoadContext.AssetStore.ObjectDefinitions.GetByName("GenericDebris"); var debrisObject = context.GameContext.GameObjects.Add(debrisObjectDefinition, context.GameObject.Owner); var lifeTime = context.GameContext.GetRandomLogicFrameSpan(MinLifetime, MaxLifetime); debrisObject.LifeTime = context.LogicFrame + lifeTime; debrisObject.UpdateTransform(context.GameObject.Translation + Offset, context.GameObject.Rotation); // Model var w3dDebrisDraw = (W3dDebrisDraw)debrisObject.Drawable.DrawModules[0]; // TODO //var modelName = ModelNames[context.GameContext.Random.Next(ModelNames.Length)]; var modelName = ModelNames[0]; w3dDebrisDraw.SetModelName(modelName); // Physics var physicsBehavior = debrisObject.FindBehavior <PhysicsBehavior>(); physicsBehavior.Mass = Mass; if (Disposition.Get(ObjectDisposition.SendItFlying)) { physicsBehavior.AddForce( new Vector3( ((float)context.GameContext.Random.NextDouble() - 0.5f) * DispositionIntensity * 200, ((float)context.GameContext.Random.NextDouble() - 0.5f) * DispositionIntensity * 200, DispositionIntensity * 200)); } // TODO: Count, Disposition, DispositionIntensity return(new List <GameObject> { debrisObject }); }
internal override List <GameObject> Execute(BehaviorUpdateContext context, Vector3?position) { var debrisObject = context.GameContext.GameObjects.Add("GenericDebris", context.GameObject.Owner); var lifeTime = context.GameContext.Random.NextDouble() * (MaxLifetime - MinLifetime) + MinLifetime; debrisObject.LifeTime = context.Time.TotalTime + TimeSpan.FromMilliseconds(lifeTime); debrisObject.UpdateTransform(context.GameObject.Translation + Offset, context.GameObject.Rotation); // Model var w3dDebrisDraw = (W3dDebrisDraw)debrisObject.Drawable.DrawModules[0]; // TODO //var modelName = ModelNames[context.GameContext.Random.Next(ModelNames.Length)]; var modelName = ModelNames[0]; w3dDebrisDraw.SetModelName(modelName); // Physics var physicsBehavior = debrisObject.FindBehavior <PhysicsBehavior>(); physicsBehavior.Mass = Mass; if (Disposition.Get(ObjectDisposition.SendItFlying)) { physicsBehavior.AddForce( new Vector3( ((float)context.GameContext.Random.NextDouble() - 0.5f) * DispositionIntensity * 200, ((float)context.GameContext.Random.NextDouble() - 0.5f) * DispositionIntensity * 200, DispositionIntensity * 200)); } // TODO: Count, Disposition, DispositionIntensity return(new List <GameObject> { debrisObject }); }