public PhysicsUnit(Item item, Dictionary<int, PhysicsUnit> items) { this.item = item; this.items = items; moving = item.GetProperty<WalkingProperty>(); collidable = item.GetProperty<CollidableProperty>(); carrier = item.GetProperty<CarrierProperty>(); portable = item.GetProperty<PortableProperty>(); map = item.Engine.Map; mapSize = map.GetSize(); // Attach Item Stuff item.CellChanged += item_CellChanged; // Attach Moving Stuff if (moving != null) { moving.OnMaximumMoveSpeedChanged += moving_OnMaximumMoveSpeedChanged; moving.OnMoveDirectionChanged += moving_OnMoveDirectionChanged; moving.OnMoveSpeedChanged += moving_OnMoveSpeedChanged; moving.MoveMalus = 1; } // Attach Collision Stuff if (collidable != null) { collidable.OnCollisionMassChanged += collidable_OnCollisionMassChanged; collidable.OnCollisionFixedChanged += collidable_OnCollisionFixedChanged; } // Attach Carrier Stuff if (carrier != null) { carrier.OnCarrierLoadChanged += carrier_OnCarrierLoadChanged; carrier.OnCarrierStrengthChanged += carrier_OnCarrierStrengthChanged; } // Attach Portable Stuff if (portable != null) { portable.OnPortableWeightChanged += portable_OnPortableMassChanged; portable.OnNewCarrierItem += portable_OnNewCarrierItem; portable.OnLostCarrierItem += portable_OnLostCarrierItem; clusterUnits = new HashSet<PhysicsUnit>(); } Recalc(); }
/// <summary> /// Default Constructor for the Type Mapper. /// </summary> /// <param name="item">Related Engine Item</param> /// <param name="property">Related Engine Property</param> public WalkingState(Item item, WalkingProperty property) : base(item, property) { // Bind Speed to the Item Speed Speed = property.Speed; property.OnMoveSpeedChanged += (i, v) => { Speed = v; }; // Bind Maximum Speed to the Item Maximum Speed MaximumSpeed = property.MaximumSpeed; property.OnMaximumMoveSpeedChanged += (i, v) => { MaximumSpeed = v; }; // Bind Direction to the Item Direction Direction = (short)property.Direction.Degree; property.OnMoveDirectionChanged += (i, v) => { Direction = (short)v.Degree; }; }