/// <summary> /// Create a GameObject with a certain amount of health, possible active, and /// can fire a GameObjectCreatedEvent /// </summary> /// <param name="manager">The manager which will fire the GameObjectCreatedEvent</param> /// <param name="health"></param> /// <param name="active"></param> /// <param name="fireOnCreateEvent"></param> public GameObject(GameEventManager manager, int health, bool active, bool fireOnCreateEvent) { ColorScheme = new ColorScheme<Hostility>(); PhysicsComponent = new PhysicsComponent(); Behaviors = new List<IBehavior>(); Active = active; Timescale = 1; Health = health; if (fireOnCreateEvent && GameEventManager != null) GameEventManager.AddEvent(new GameObjectCreatedEvent(this)); }
/// <summary> /// Copy constructor /// </summary> /// <param name="other"></param> public PhysicsComponent(PhysicsComponent other) { Position = other.Position.Copy(); Velocity = other.Velocity.Copy(); Acceleration = other.Acceleration.Copy(); Dimensions = other.Dimensions.Copy(); DecayAcceleration = other.DecayAcceleration.Copy(); Rotation = other.Rotation; Mass = other.Mass; MaxSpeed = other.MaxSpeed; }
/// <summary> /// Copy another Gameobject. Optionally fire a GameObjectCreatedEvent /// </summary> /// <param name="other"></param> /// <param name="fireOnCreateEvent"></param> public GameObject(GameObject other, bool fireOnCreateEvent=true) { ColorScheme = new ColorScheme<Hostility>(other.ColorScheme); GameEventManager = other.GameEventManager; PhysicsComponent = new PhysicsComponent(other.PhysicsComponent); Behaviors = new List<IBehavior>(other.Behaviors); Active = other.Active; Timescale = other.Timescale; Health = other.Health; if (fireOnCreateEvent && GameEventManager != null) GameEventManager.AddEvent(new GameObjectCreatedEvent(this)); }