Implement magboots. (#2988)

Got an alert and action and everything.
This commit is contained in:
Pieter-Jan Briers
2021-01-11 19:24:09 +01:00
committed by GitHub
parent 32c14b0e51
commit 052ea49884
15 changed files with 380 additions and 23 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Content.Shared.GameObjects.Components.Movement;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Reflection;
@@ -11,7 +12,7 @@ using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefine
namespace Content.Shared.GameObjects.Components.Inventory
{
public abstract class SharedInventoryComponent : Component
public abstract class SharedInventoryComponent : Component, IMoveSpeedModifier
{
// ReSharper disable UnassignedReadonlyField
[Dependency] protected readonly IReflectionManager ReflectionManager;
@@ -100,5 +101,8 @@ namespace Content.Shared.GameObjects.Components.Inventory
Slot = slot;
}
}
public abstract float WalkSpeedModifier { get; }
public abstract float SprintSpeedModifier { get; }
}
}

View File

@@ -1,4 +1,6 @@
using Robust.Shared.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -54,6 +56,15 @@ namespace Content.Shared.GameObjects.Components.Movement
_movespeedModifiersNeedRefresh = true;
}
public static void RefreshItemModifiers(IEntity item)
{
if (item.TryGetContainer(out var container) &&
container.Owner.TryGetComponent(out MovementSpeedModifierComponent mod))
{
mod.RefreshMovementSpeedModifiers();
}
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);

View File

@@ -0,0 +1,35 @@
using System;
using Content.Shared.GameObjects.Components.Movement;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components
{
public abstract class SharedMagbootsComponent : Component, IMoveSpeedModifier
{
public sealed override string Name => "Magboots";
public sealed override uint? NetID => ContentNetIDs.MAGBOOTS;
public abstract bool On { get; set; }
protected void OnChanged()
{
MovementSpeedModifierComponent.RefreshItemModifiers(Owner);
}
public float WalkSpeedModifier => On ? 0.85f : 1;
public float SprintSpeedModifier => On ? 0.65f : 1;
[Serializable, NetSerializable]
public sealed class MagbootsComponentState : ComponentState
{
public bool On { get; }
public MagbootsComponentState(bool @on) : base(ContentNetIDs.MAGBOOTS)
{
On = on;
}
}
}
}

View File

@@ -88,6 +88,7 @@
public const uint REAGENT_GRINDER = 1082;
public const uint ACTIONS = 1083;
public const uint DAMAGEABLE = 1084;
public const uint MAGBOOTS = 1085;
// Net IDs for integration tests.
public const uint PREDICTION_TEST = 10001;