Ejemplo n.º 1
0
        private void HandleGravityInitialize(EntityUid uid, GravityComponent component, ComponentInit args)
        {
            // Incase there's already a generator on the grid we'll just set it now.
            var gridId = Transform(component.Owner).GridUid;

            if (gridId == null)
            {
                return;
            }

            GravityChangedMessage message;

            foreach (var generator in EntityManager.EntityQuery <GravityGeneratorComponent>())
            {
                if (Transform(generator.Owner).GridUid == gridId && generator.GravityActive)
                {
                    component.Enabled = true;
                    message           = new GravityChangedMessage(gridId.Value, true);
                    RaiseLocalEvent(message);
                    return;
                }
            }

            component.Enabled = false;
            message           = new GravityChangedMessage(gridId.Value, false);
            RaiseLocalEvent(message);
        }
Ejemplo n.º 2
0
        private void DisableGravity(IMapGrid grid)
        {
            grid.HasGravity = false;
            ScheduleGridToShake(grid.Index, ShakeTimes);

            var message = new GravityChangedMessage(grid);

            RaiseLocalEvent(message);
        }
Ejemplo n.º 3
0
        public void DisableGravity(GravityComponent comp)
        {
            if (!comp.Enabled)
            {
                return;
            }
            comp.Enabled = false;

            var gridId  = EntityManager.GetComponent <TransformComponent>(comp.Owner).GridID;
            var message = new GravityChangedMessage(gridId, false);

            RaiseLocalEvent(message);
        }
Ejemplo n.º 4
0
        public void DisableGravity(GravityComponent comp)
        {
            if (!comp.Enabled)
            {
                return;
            }
            comp.Enabled = false;

            var gridId = Transform(comp.Owner).GridUid;

            if (gridId == null)
            {
                return;
            }

            var message = new GravityChangedMessage(gridId.Value, false);

            RaiseLocalEvent(message);
        }
Ejemplo n.º 5
0
        private void GravityChanged(GravityChangedMessage ev)
        {
            if (!_alerts.TryGetValue(ev.Grid.Index, out var statuses))
            {
                return;
            }

            if (ev.HasGravity)
            {
                foreach (var status in statuses)
                {
                    RemoveWeightless(status);
                }
            }
            else
            {
                foreach (var status in statuses)
                {
                    AddWeightless(status);
                }
            }
        }