示例#1
0
        private void OnHandleState(EntityUid uid, StatusEffectsComponent component, ref ComponentHandleState args)
        {
            if (args.Current is not StatusEffectsComponentState state)
            {
                return;
            }

            component.AllowedEffects = new(state.AllowedEffects);

            // Remove non-existent effects.
            foreach (var effect in component.ActiveEffects.Keys)
            {
                if (!state.ActiveEffects.ContainsKey(effect))
                {
                    TryRemoveStatusEffect(uid, effect, component);
                }
            }

            foreach (var effect in state.ActiveEffects)
            {
                // don't bother with anything if we already have it
                if (component.ActiveEffects.ContainsKey(effect.Key))
                {
                    component.ActiveEffects[effect.Key] = effect.Value;
                    continue;
                }

                var time = effect.Value.Cooldown.Item2 - effect.Value.Cooldown.Item1;
                //TODO: Not sure how to handle refresh here.
                TryAddStatusEffect(uid, effect.Key, time, true);
            }
        }
 private void OnHandleState(EntityUid uid, SharedClothingComponent component, ref ComponentHandleState args)
 {
     if (args.Current is ClothingComponentState state)
     {
         component.EquippedPrefix = state.EquippedPrefix;
     }
 }
示例#3
0
        private void OnHandleState(EntityUid uid, PilotComponent component, ref ComponentHandleState args)
        {
            if (args.Current is not PilotComponentState state)
            {
                return;
            }

            var console = state.Console.GetValueOrDefault();

            if (!console.IsValid())
            {
                component.Console = null;
                _input.Contexts.SetActiveContext("human");
                return;
            }

            if (!TryComp <ShuttleConsoleComponent>(console, out var shuttleConsoleComponent))
            {
                Logger.Warning($"Unable to set Helmsman console to {console}");
                return;
            }

            component.Console = shuttleConsoleComponent;
            ActionBlockerSystem.UpdateCanMove(uid);
            _input.Contexts.SetActiveContext("shuttle");
        }
示例#4
0
        private void HandleComponentState(EntityUid uid, HandsComponent component, ref ComponentHandleState args)
        {
            if (args.Current is not HandsComponentState state)
            {
                return;
            }

            // Do we have a NEW hand?
            var handsModified = component.Hands.Count != state.Hands.Count;

            if (!handsModified)
            {
                for (var i = 0; i < state.Hands.Count; i++)
                {
                    if (component.Hands[i].Name != state.Hands[i].Name ||
                        component.Hands[i].Location != state.Hands[i].Location)
                    {
                        handsModified = true;
                        break;
                    }
                }
            }

            if (handsModified)
            {
                // we have new hands, get the new containers.
                component.Hands = state.Hands;
                UpdateHandContainers(uid, component);
            }

            TrySetActiveHand(uid, state.ActiveHand, component);
        }
 private void OnSlowHandleState(EntityUid uid, SlowedDownComponent component, ref ComponentHandleState args)
 {
     if (args.Current is SlowedDownComponentState state)
     {
         component.SprintSpeedModifier = state.SprintSpeedModifier;
         component.WalkSpeedModifier   = state.WalkSpeedModifier;
     }
 }
示例#6
0
 private void OnHandleState(EntityUid uid, RadarConsoleComponent component, ref ComponentHandleState args)
 {
     if (args.Current is not RadarConsoleComponentState state)
     {
         return;
     }
     component.MaxRange = state.Range;
 }
 private void OnComponentHandleState(EntityUid uid, IdCardComponent component, ref ComponentHandleState args)
 {
     if (args.Current is IdCardComponentState state)
     {
         component.FullName = state.FullName;
         component.JobTitle = state.JobTitle;
     }
 }
示例#8
0
 private void OnMobHandleState(EntityUid uid, MobMoverComponent component, ref ComponentHandleState args)
 {
     if (args.Current is not MobMoverComponentState state)
     {
         return;
     }
     component.GrabRangeVV    = state.GrabRange;
     component.PushStrengthVV = state.PushStrength;
 }
    private void OnHandleState(EntityUid uid, PreventCollideComponent component, ref ComponentHandleState args)
    {
        if (args.Current is not PreventCollideComponentState state)
        {
            return;
        }

        component.Uid = state.Uid;
    }
示例#10
0
        private void OnHandleState(EntityUid uid, StandingStateComponent component, ref ComponentHandleState args)
        {
            if (args.Current is not StandingComponentState state)
            {
                return;
            }

            component.Standing = state.Standing;
        }
示例#11
0
    private void OnHandleState(EntityUid uid, SharedAirlockComponent airlock, ref ComponentHandleState args)
    {
        if (args.Current is not AirlockComponentState state)
        {
            return;
        }

        airlock.Safety = state.Safety;
    }
示例#12
0
 private void OnHandleState(EntityUid uid, ProjectileComponent component, ref ComponentHandleState args)
 {
     if (args.Current is not ProjectileComponentState state)
     {
         return;
     }
     component.Shooter       = state.Shooter;
     component.IgnoreShooter = state.IgnoreShooter;
 }
示例#13
0
    private void OnHandleState(EntityUid uid, HandheldLightComponent component, ref ComponentHandleState args)
    {
        if (args.Current is not SharedHandheldLightComponent.HandheldLightComponentState state)
        {
            return;
        }

        component.Level = state.Charge;
    }
示例#14
0
        private void HandleComponentState(EntityUid uid, JointComponent component, ref ComponentHandleState args)
        {
            if (args.Current is not JointComponent.JointComponentState jointState)
            {
                return;
            }

            var changed = new List <string>();

            foreach (var(existing, _) in component.Joints)
            {
                if (!jointState.Joints.ContainsKey(existing))
                {
                    changed.Add(existing);
                }
            }

            foreach (var removed in changed)
            {
                RemoveJoint(component.Joints[removed]);
            }

            foreach (var(id, state) in jointState.Joints)
            {
                Joint joint;

                if (!component.Joints.ContainsKey(id))
                {
                    // Add new joint (if possible).
                    // Need to wait for BOTH joint components to come in first before we can add it. Yay dependencies!
                    if (!EntityManager.HasComponent <JointComponent>(state.UidA) ||
                        !EntityManager.HasComponent <JointComponent>(state.UidB))
                    {
                        continue;
                    }

                    joint = state.GetJoint();
                    AddJoint(joint);
                    continue;
                }

                joint = state.GetJoint();
                var existing = component.Joints[id];

                if (!existing.Equals(joint))
                {
                    existing.ApplyState(state);
                    component.Dirty();
                }
            }

            if (changed.Count > 0)
            {
                component.Dirty();
            }
        }
示例#15
0
    private void OnHandleState(EntityUid uid, FlyBySoundComponent component, ref ComponentHandleState args)
    {
        if (args.Current is not FlyBySoundComponentState state)
        {
            return;
        }

        component.Sound = state.Sound;
        component.Range = state.Range;
    }
示例#16
0
 private void HandleCompState(EntityUid uid, AmbientSoundComponent component, ref ComponentHandleState args)
 {
     if (args.Current is not AmbientSoundComponentState state)
     {
         return;
     }
     component.Enabled = state.Enabled;
     component.Range   = state.Range;
     component.Volume  = state.Volume;
 }
示例#17
0
        private void OnHandleState(EntityUid uid, SharedItemComponent component, ref ComponentHandleState args)
        {
            if (args.Current is not ItemComponentState state)
            {
                return;
            }

            component.Size           = state.Size;
            component.EquippedPrefix = state.EquippedPrefix;
        }
        private void OnHandleState(EntityUid uid, JitteringComponent component, ref ComponentHandleState args)
        {
            if (args.Current is not JitteringComponentState jitteringState)
            {
                return;
            }

            component.Amplitude = jitteringState.Amplitude;
            component.Frequency = jitteringState.Frequency;
        }
    private static void OnClimbingState(EntityUid uid, ClimbingComponent component, ref ComponentHandleState args)
    {
        if (args.Current is not SharedClimbingComponent.ClimbModeComponentState climbModeState)
        {
            return;
        }

        component.IsClimbing           = climbModeState.Climbing;
        component.OwnerIsTransitioning = climbModeState.IsTransitioning;
    }
        private void OnRiderHandleState(EntityUid uid, RiderComponent component, ref ComponentHandleState args)
        {
            // Server should only be sending states for our entity.
            if (args.Current is not RiderComponentState state)
            {
                return;
            }
            component.Vehicle = state.Entity;

            UpdateEye(component);
        }
示例#21
0
        private void OnWelderHandleState(EntityUid uid, WelderComponent welder, ref ComponentHandleState args)
        {
            if (args.Current is not WelderComponentState state)
            {
                return;
            }

            welder.FuelCapacity   = state.FuelCapacity;
            welder.Fuel           = state.Fuel;
            welder.Lit            = state.Lit;
            welder.UiUpdateNeeded = true;
        }
示例#22
0
 private void OnStrapHandleState(EntityUid uid, StrapComponent component, ref ComponentHandleState args)
 {
     if (args.Current is not StrapComponentState state)
     {
         return;
     }
     component.Position = state.Position;
     component.BuckleOffsetUnclamped = state.BuckleOffsetClamped;
     component.BuckledEntities.Clear();
     component.BuckledEntities.UnionWith(state.BuckledEntities);
     component.MaxBuckleDistance = state.MaxBuckleDistance;
 }
示例#23
0
        private void OnDoAfterHandleState(EntityUid uid, DoAfterComponent component, ref ComponentHandleState args)
        {
            if (args.Current is not DoAfterComponentState state)
            {
                return;
            }

            var toRemove = new RemQueue <ClientDoAfter>();

            foreach (var(id, doAfter) in component.DoAfters)
            {
                var found = false;

                foreach (var clientdoAfter in state.DoAfters)
                {
                    if (clientdoAfter.ID == id)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    toRemove.Add(doAfter);
                }
            }

            foreach (var doAfter in toRemove)
            {
                Remove(component, doAfter);
            }

            foreach (var doAfter in state.DoAfters)
            {
                if (component.DoAfters.ContainsKey(doAfter.ID))
                {
                    continue;
                }

                component.DoAfters.Add(doAfter.ID, doAfter);
            }

            if (component.Gui == null || component.Gui.Disposed)
            {
                return;
            }

            foreach (var(_, doAfter) in component.DoAfters)
            {
                component.Gui.AddDoAfter(doAfter);
            }
        }
        private void OnHandleState(EntityUid uid, ThrownItemComponent component, ref ComponentHandleState args)
        {
            if (args.Current is not ThrownItemComponentState {
                Thrower : not null
            } state ||
                !state.Thrower.Value.IsValid())
            {
                return;
            }

            component.Thrower = state.Thrower.Value;
        }
示例#25
0
        private void OnHandleState(EntityUid uid, RgbLightControllerComponent rgb, ref ComponentHandleState args)
        {
            if (args.Current is not RgbLightControllerState state)
            {
                return;
            }

            ResetOriginalColors(uid, rgb);
            rgb.CycleRate = state.CycleRate;
            rgb.Layers    = state.Layers;
            GetOriginalColors(uid, rgb);
        }
        private void OnHandleState(EntityUid uid, ThrownItemComponent component, ref ComponentHandleState args)
        {
            if (args.Current is not ThrownItemComponentState state || state.Thrower == null)
            {
                return;
            }

            if (EntityManager.TryGetEntity(state.Thrower.Value, out var entity))
            {
                component.Thrower = entity;
            }
        }
    private void OnHandleState(EntityUid uid, FoldableComponent component, ref ComponentHandleState args)
    {
        if (args.Current is not FoldableComponentState state)
        {
            return;
        }

        if (state.IsFolded != component.IsFolded)
        {
            SetFolded(component, state.IsFolded);
        }
    }
示例#28
0
        private void HandleCompState(EntityUid uid, PinpointerComponent pinpointer, ref ComponentHandleState args)
        {
            if (args.Current is not PinpointerComponentState state)
            {
                return;
            }
            SetActive(uid, state.IsActive, pinpointer);
            SetDirection(uid, state.DirectionToTarget, pinpointer);
            SetDistance(uid, state.DistanceToTarget, pinpointer);

            UpdateAppearance(uid, pinpointer);
            UpdateEyeDir(uid, pinpointer);
        }
示例#29
0
    private void OnParallaxHandleState(EntityUid uid, ParallaxComponent component, ref ComponentHandleState args)
    {
        if (args.Current is not ParallaxComponentState state)
        {
            return;
        }
        component.Parallax = state.Parallax;

        if (!_parallax.IsLoaded(component.Parallax))
        {
            _parallax.LoadParallaxByName(component.Parallax);
        }
    }
示例#30
0
        private void OnHandleState(EntityUid uid, RgbLightControllerComponent rgb, ref ComponentHandleState args)
        {
            if (args.Current is not RgbLightControllerState state)
            {
                return;
            }

            ResetSpriteColors(uid, rgb);
            rgb.CycleRate = state.CycleRate;
            rgb.Layers    = state.Layers;

            // get the new original sprite colors (necessary if rgb.Layers was updated).
            GetOriginalSpriteColors(uid, rgb);
        }