Ejemplo n.º 1
0
        private HealthModifiedInfo HandleModifyHealthRequest(HealthModifier modifier, ref HealthComponent.Component healthComp)
        {
            var newHealth = Mathf.Clamp(healthComp.Health + modifier.Amount, 0, healthComp.MaxHealth);
            var died      = newHealth <= 0;

            var healthModifiedInfo = new HealthModifiedInfo(
                modifier: modifier,
                healthBefore: healthComp.Health,
                healthAfter: newHealth,
                died: died);

            healthComp.Health = newHealth;

            return(healthModifiedInfo);
        }
Ejemplo n.º 2
0
 public static void Serialize(HealthModifier instance, global::Improbable.Worker.CInterop.SchemaObject obj)
 {
     {
         obj.AddUint32(1, instance.Type);
     }
     {
         obj.AddFloat(2, instance.Amount);
     }
     {
         global::Improbable.Gdk.Standardtypes.IntAbsolute.Serialization.Serialize(instance.AppliedLocation, obj.AddObject(3));
     }
     {
         global::Improbable.Gdk.Standardtypes.IntAbsolute.Serialization.Serialize(instance.Origin, obj.AddObject(4));
     }
 }
Ejemplo n.º 3
0
            public static HealthModifier Deserialize(global::Improbable.Worker.CInterop.SchemaObject obj)
            {
                var instance = new HealthModifier();

                {
                    instance.Type = obj.GetUint32(1);
                }
                {
                    instance.Amount = obj.GetFloat(2);
                }
                {
                    instance.AppliedLocation = global::Improbable.Gdk.Standardtypes.IntAbsolute.Serialization.Deserialize(obj.GetObject(3));
                }
                {
                    instance.Origin = global::Improbable.Gdk.Standardtypes.IntAbsolute.Serialization.Deserialize(obj.GetObject(4));
                }
                return(instance);
            }