Example #1
0
 public void OnCharacterStatsInvalidated(CharacterStatsInvalidated message)
 {
     foreach (var component in Manager.GetComponents(message.Entity, AbstractRegeneratingValue.TypeId))
     {
         ((AbstractRegeneratingValue)component).RecomputeValues();
     }
 }
Example #2
0
        public void OnCharacterStatsInvalidated(CharacterStatsInvalidated message)
        {
            var entity   = message.Entity;
            var shipInfo = ((ShipInfo)Manager.GetComponent(entity, ShipInfo.TypeId));

            if (shipInfo == null)
            {
                // Skip if there's no ship info here (other entities with attributes,
                // such as damagers -- e.g. suns).
                return;
            }

            // Get ship modules.
            var attributes =
                (Attributes <AttributeType>)Manager.GetComponent(entity, Attributes <AttributeType> .TypeId);

            // Get the mass of the ship and return it.
            shipInfo.Mass = attributes.GetValue(AttributeType.Mass);

            // Recompute cached values.
            shipInfo.MaxAcceleration = attributes.GetValue(AttributeType.AccelerationForce);
            shipInfo.MaxSpeed        = float.PositiveInfinity;

            // Maximum speed.
            shipInfo.MaxSpeed = shipInfo.MaxAcceleration / (ShipFactory.LinearDamping * shipInfo.Mass);

            // Figure out the overall range of our radar system.
            shipInfo.RadarRange = attributes.GetValue(AttributeType.SensorRange);

            // TODO: compute actual range
            shipInfo.WeaponRange = 10;
        }
Example #3
0
        public void OnCharacterStatsInvalidated(CharacterStatsInvalidated message)
        {
            // Module removed or added, recompute mass.
            var entity      = message.Entity;
            var attributes  = (Attributes <AttributeType>)Manager.GetComponent(entity, Attributes <AttributeType> .TypeId);
            var gravitation = Manager.GetComponent(entity, Gravitation.TypeId) as Gravitation;

            if (gravitation != null)
            {
                // Get the mass of the object and return it.
                gravitation.Mass = Math.Max(1, attributes.GetValue(AttributeType.Mass));
            }
        }
Example #4
0
 public void OnCharacterStatsInvalidated(CharacterStatsInvalidated message)
 {
     _changedMass.Add(message.Entity);
 }