Re-organize all projects (#4166)

This commit is contained in:
DrSmugleaf
2021-06-09 22:19:39 +02:00
committed by GitHub
parent 9f50e4061b
commit ff1a2d97ea
1773 changed files with 5258 additions and 5508 deletions

View File

@@ -0,0 +1,109 @@
#nullable enable
using System;
using System.Collections.Generic;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Shared.Disposal.Components
{
public abstract class SharedDisposalMailingUnitComponent : SharedDisposalUnitComponent
{
public override string Name => "DisposalMailingUnit";
public const string TAGS_MAIL = "mail";
public const string NET_TAG = "tag";
public const string NET_SRC = "src";
public const string NET_TARGET = "target";
public const string NET_CMD_SENT = "mail_sent";
public const string NET_CMD_REQUEST = "get_mailer_tag";
public const string NET_CMD_RESPONSE = "mailer_tag";
[Serializable, NetSerializable]
public new enum UiButton : byte
{
Eject,
Engage,
Power
}
[Serializable, NetSerializable]
public class DisposalMailingUnitBoundUserInterfaceState : BoundUserInterfaceState, IEquatable<DisposalMailingUnitBoundUserInterfaceState>, ICloneable
{
public readonly string UnitName;
public readonly string UnitState;
public readonly float Pressure;
public readonly bool Powered;
public readonly bool Engaged;
public readonly string Tag;
public readonly List<string> Tags;
public readonly string? Target;
public DisposalMailingUnitBoundUserInterfaceState(string unitName, string unitState, float pressure, bool powered,
bool engaged, string tag, List<string> tags, string? target)
{
UnitName = unitName;
UnitState = unitState;
Pressure = pressure;
Powered = powered;
Engaged = engaged;
Tag = tag;
Tags = tags;
Target = target;
}
public object Clone()
{
return new DisposalMailingUnitBoundUserInterfaceState(UnitName, UnitState, Pressure, Powered, Engaged, Tag, (List<string>)Tags.Clone(), Target);
}
public bool Equals(DisposalMailingUnitBoundUserInterfaceState? other)
{
if (other is null) return false;
if (ReferenceEquals(this, other)) return true;
return UnitName == other.UnitName &&
UnitState == other.UnitState &&
Powered == other.Powered &&
Engaged == other.Engaged &&
Pressure.Equals(other.Pressure) &&
Tag == other.Tag &&
Target == other.Target;
}
}
/// <summary>
/// Message data sent from client to server when a mailing unit ui button is pressed.
/// </summary>
[Serializable, NetSerializable]
public new class UiButtonPressedMessage : BoundUserInterfaceMessage
{
public readonly UiButton Button;
public UiButtonPressedMessage(UiButton button)
{
Button = button;
}
}
/// <summary>
/// Message data sent from client to server when the mailing units target is updated.
/// </summary>
[Serializable, NetSerializable]
public class UiTargetUpdateMessage : BoundUserInterfaceMessage
{
public readonly string? Target;
public UiTargetUpdateMessage(string? target)
{
Target = target;
}
}
[Serializable, NetSerializable]
public enum DisposalMailingUnitUiKey
{
Key
}
}
}

View File

@@ -0,0 +1,55 @@
#nullable enable
using System;
using System.Text.RegularExpressions;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.Disposal.Components
{
public class SharedDisposalRouterComponent : Component
{
public override string Name => "DisposalRouter";
public static readonly Regex TagRegex = new("^[a-zA-Z0-9, ]*$", RegexOptions.Compiled);
[Serializable, NetSerializable]
public class DisposalRouterUserInterfaceState : BoundUserInterfaceState
{
public readonly string Tags;
public DisposalRouterUserInterfaceState(string tags)
{
Tags = tags;
}
}
[Serializable, NetSerializable]
public class UiActionMessage : BoundUserInterfaceMessage
{
public readonly UiAction Action;
public readonly string Tags = "";
public UiActionMessage(UiAction action, string tags)
{
Action = action;
if (Action == UiAction.Ok)
{
Tags = tags.Substring(0, Math.Min(tags.Length, 150));
}
}
}
[Serializable, NetSerializable]
public enum UiAction
{
Ok
}
[Serializable, NetSerializable]
public enum DisposalRouterUiKey
{
Key
}
}
}

View File

@@ -0,0 +1,55 @@
#nullable enable
using System;
using System.Text.RegularExpressions;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.Disposal.Components
{
public class SharedDisposalTaggerComponent : Component
{
public override string Name => "DisposalTagger";
public static readonly Regex TagRegex = new("^[a-zA-Z0-9 ]*$", RegexOptions.Compiled);
[Serializable, NetSerializable]
public class DisposalTaggerUserInterfaceState : BoundUserInterfaceState
{
public readonly string Tag;
public DisposalTaggerUserInterfaceState(string tag)
{
Tag = tag;
}
}
[Serializable, NetSerializable]
public class UiActionMessage : BoundUserInterfaceMessage
{
public readonly UiAction Action;
public readonly string Tag = "";
public UiActionMessage(UiAction action, string tag)
{
Action = action;
if (Action == UiAction.Ok)
{
Tag = tag.Substring(0, Math.Min(tag.Length, 30));
}
}
}
[Serializable, NetSerializable]
public enum UiAction
{
Ok
}
[Serializable, NetSerializable]
public enum DisposalTaggerUiKey
{
Key
}
}
}

View File

@@ -0,0 +1,20 @@
#nullable enable
using System;
using Robust.Shared.Serialization;
namespace Content.Shared.Disposal.Components
{
[Serializable, NetSerializable]
public enum DisposalTubeVisuals
{
VisualState
}
[Serializable, NetSerializable]
public enum DisposalTubeVisualState
{
Free = 0,
Anchored,
Broken,
}
}

View File

@@ -0,0 +1,157 @@
#nullable enable
using System;
using Content.Shared.Body.Components;
using Content.Shared.DragDrop;
using Content.Shared.Item;
using Content.Shared.MobState;
using Robust.Shared.GameObjects;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Shared.Disposal.Components
{
public abstract class SharedDisposalUnitComponent : Component, IDragDropOn
{
public override string Name => "DisposalUnit";
[ViewVariables]
public bool Anchored =>
!Owner.TryGetComponent(out IPhysBody? physics) ||
physics.BodyType == BodyType.Static;
[Serializable, NetSerializable]
public enum Visuals
{
VisualState,
Handle,
Light
}
[Serializable, NetSerializable]
public enum VisualState
{
UnAnchored,
Anchored,
Flushing,
Charging
}
[Serializable, NetSerializable]
public enum HandleState
{
Normal,
Engaged
}
[Serializable, NetSerializable]
public enum LightState
{
Off,
Charging,
Full,
Ready
}
[Serializable, NetSerializable]
public enum UiButton
{
Eject,
Engage,
Power
}
[Serializable, NetSerializable]
public enum PressureState
{
Ready,
Pressurizing
}
public virtual void Update(float frameTime)
{
return;
}
[Serializable, NetSerializable]
public class DisposalUnitBoundUserInterfaceState : BoundUserInterfaceState, IEquatable<DisposalUnitBoundUserInterfaceState>
{
public readonly string UnitName;
public readonly string UnitState;
public readonly float Pressure;
public readonly bool Powered;
public readonly bool Engaged;
public DisposalUnitBoundUserInterfaceState(string unitName, string unitState, float pressure, bool powered,
bool engaged)
{
UnitName = unitName;
UnitState = unitState;
Pressure = pressure;
Powered = powered;
Engaged = engaged;
}
public bool Equals(DisposalUnitBoundUserInterfaceState? other)
{
if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;
return UnitName == other.UnitName &&
UnitState == other.UnitState &&
Powered == other.Powered &&
Engaged == other.Engaged &&
Pressure.Equals(other.Pressure);
}
}
/// <summary>
/// Message data sent from client to server when a disposal unit ui button is pressed.
/// </summary>
[Serializable, NetSerializable]
public class UiButtonPressedMessage : BoundUserInterfaceMessage
{
public readonly UiButton Button;
public UiButtonPressedMessage(UiButton button)
{
Button = button;
}
}
[Serializable, NetSerializable]
public enum DisposalUnitUiKey
{
Key
}
public virtual bool CanInsert(IEntity entity)
{
if (!Anchored)
return false;
// TODO: Probably just need a disposable tag.
if (!entity.TryGetComponent(out SharedItemComponent? storable) &&
!entity.HasComponent<IBody>())
{
return false;
}
if (!entity.TryGetComponent(out IPhysBody? physics) ||
!physics.CanCollide && storable == null)
{
if (!(entity.TryGetComponent(out IMobStateComponent? damageState) && damageState.IsDead())) {
return false;
}
}
return true;
}
public virtual bool CanDragDropOn(DragDropEvent eventArgs)
{
return CanInsert(eventArgs.Dragged);
}
public abstract bool DragDropOn(DragDropEvent eventArgs);
}
}