Esempio n. 1
0
        private void HandleCollide(EntityUid uid, FlammableComponent component, StartCollideEvent args)
        {
            if (!args.OtherFixture.Body.Owner.TryGetComponent(out FlammableComponent? otherFlammable))
            {
                return;
            }

            if (!component.FireSpread || !otherFlammable.FireSpread)
            {
                return;
            }

            if (component.OnFire)
            {
                if (otherFlammable.OnFire)
                {
                    var fireSplit = (component.FireStacks + otherFlammable.FireStacks) / 2;
                    component.FireStacks      = fireSplit;
                    otherFlammable.FireStacks = fireSplit;
                }
                else
                {
                    component.FireStacks      /= 2;
                    otherFlammable.FireStacks += component.FireStacks;
                    Ignite(otherFlammable);
                }
            }
            else if (otherFlammable.OnFire)
            {
                otherFlammable.FireStacks /= 2;
                component.FireStacks      += otherFlammable.FireStacks;
                Ignite(component);
            }
        }
Esempio n. 2
0
        internal void Ignite(FlammableComponent component)
        {
            if (component.FireStacks > 0 && !component.OnFire)
            {
                component.OnFire = true;
            }

            component.UpdateAppearance();
        }
        private void OnInteractUsingEvent(EntityUid uid, FlammableComponent flammable, InteractUsingEvent args)
        {
            if (args.Handled)
            {
                return;
            }

            var isHotEvent = new IsHotEvent();

            RaiseLocalEvent(args.Used.Uid, isHotEvent, false);

            if (!isHotEvent.IsHot)
            {
                return;
            }

            Ignite(uid, flammable);
            args.Handled = true;
        }
        private void OnCollideEvent(EntityUid uid, FlammableComponent flammable, StartCollideEvent args)
        {
            var otherUid = args.OtherFixture.Body.Owner.Uid;

            if (!EntityManager.TryGetComponent(otherUid, out FlammableComponent? otherFlammable))
            {
                return;
            }

            if (!flammable.FireSpread || !otherFlammable.FireSpread)
            {
                return;
            }

            if (flammable.OnFire)
            {
                if (otherFlammable.OnFire)
                {
                    var fireSplit = (flammable.FireStacks + otherFlammable.FireStacks) / 2;
                    flammable.FireStacks      = fireSplit;
                    otherFlammable.FireStacks = fireSplit;
                }
                else
                {
                    flammable.FireStacks      /= 2;
                    otherFlammable.FireStacks += flammable.FireStacks;
                    Ignite(otherUid, otherFlammable);
                }
            }
            else if (otherFlammable.OnFire)
            {
                otherFlammable.FireStacks /= 2;
                flammable.FireStacks      += otherFlammable.FireStacks;
                Ignite(uid, flammable);
            }
        }
 private void OnTileFireEvent(EntityUid uid, FlammableComponent flammable, TileFireEvent args)
 {
     AdjustFireStacks(uid, 3, flammable);
     Ignite(uid, flammable);
 }
 private void OnIsHotEvent(EntityUid uid, FlammableComponent flammable, IsHotEvent args)
 {
     args.IsHot = flammable.OnFire;
 }