ConstructionGL2 Part 2: Better guided steps and recipes. (#5103)
This commit is contained in:
committed by
GitHub
parent
5be8271907
commit
5a5006e4cf
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Maps;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Window;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -30,5 +31,13 @@ namespace Content.Shared.Construction.Conditions
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ConstructionGuideEntry? GenerateGuideEntry()
|
||||
{
|
||||
return new ConstructionGuideEntry()
|
||||
{
|
||||
Localization = "construction-guide-condition-empty-or-window-valid-in-tile"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Content.Shared.Construction.Conditions
|
||||
{
|
||||
public interface IConstructionCondition
|
||||
{
|
||||
ConstructionGuideEntry? GenerateGuideEntry();
|
||||
bool Condition(IEntity user, EntityCoordinates location, Direction direction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,5 +22,13 @@ namespace Content.Shared.Construction.Conditions
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public ConstructionGuideEntry? GenerateGuideEntry()
|
||||
{
|
||||
return new ConstructionGuideEntry()
|
||||
{
|
||||
Localization = "construction-step-condition-no-windows-in-tile"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,5 +23,13 @@ namespace Content.Shared.Construction.Conditions
|
||||
|
||||
return !tileRef.Value.IsBlockedTurf(_filterMobs);
|
||||
}
|
||||
|
||||
public ConstructionGuideEntry? GenerateGuideEntry()
|
||||
{
|
||||
return new ConstructionGuideEntry()
|
||||
{
|
||||
Localization = "construction-step-condition-tile-not-blocked",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Construction.Conditions
|
||||
{
|
||||
@@ -12,7 +13,14 @@ namespace Content.Shared.Construction.Conditions
|
||||
[DataDefinition]
|
||||
public class TileType : IConstructionCondition
|
||||
{
|
||||
[DataField("targets")] public List<string> TargetTiles { get; private set; } = new();
|
||||
[DataField("targets")]
|
||||
public List<string> TargetTiles { get; } = new();
|
||||
|
||||
[DataField("guideText")]
|
||||
public string? GuideText = null;
|
||||
|
||||
[DataField("guideIcon")]
|
||||
public SpriteSpecifier? GuideIcon = null;
|
||||
|
||||
public bool Condition(IEntity user, EntityCoordinates location, Direction direction)
|
||||
{
|
||||
@@ -32,5 +40,17 @@ namespace Content.Shared.Construction.Conditions
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public ConstructionGuideEntry? GenerateGuideEntry()
|
||||
{
|
||||
if (GuideText == null)
|
||||
return null;
|
||||
|
||||
return new ConstructionGuideEntry()
|
||||
{
|
||||
Localization = GuideText,
|
||||
Icon = GuideIcon,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,5 +50,13 @@ namespace Content.Shared.Construction.Conditions
|
||||
predicate: (e) => e == targetWall || !e.HasTag("Wall"));
|
||||
return !adjWallRaycastResults.Any();
|
||||
}
|
||||
|
||||
public ConstructionGuideEntry? GenerateGuideEntry()
|
||||
{
|
||||
return new ConstructionGuideEntry()
|
||||
{
|
||||
Localization = "construction-step-condition-wallmount",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
27
Content.Shared/Construction/ConstructionGuide.cs
Normal file
27
Content.Shared/Construction/ConstructionGuide.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Construction
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConstructionGuide
|
||||
{
|
||||
public readonly ConstructionGuideEntry[] Entries;
|
||||
|
||||
public ConstructionGuide(ConstructionGuideEntry[] entries)
|
||||
{
|
||||
Entries = entries;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConstructionGuideEntry
|
||||
{
|
||||
public int? EntryNumber { get; set; } = null;
|
||||
public int Padding { get; set; } = 0;
|
||||
public string Localization { get; set; } = string.Empty;
|
||||
public (string, object)[]? Arguments { get; set; } = null;
|
||||
public SpriteSpecifier? Icon { get; set; } = null;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Examine;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Examine;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
@@ -8,6 +9,7 @@ namespace Content.Shared.Construction
|
||||
public interface IGraphCondition
|
||||
{
|
||||
bool Condition(EntityUid uid, IEntityManager entityManager);
|
||||
bool DoExamine(ExaminedEvent args) { return false; }
|
||||
bool DoExamine(ExaminedEvent args);
|
||||
IEnumerable<ConstructionGuideEntry> GenerateGuideEntry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace Content.Shared.Construction
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Send server -> client to tell the client that a ghost has started to be constructed.
|
||||
/// Sent server -> client to tell the client that a ghost has started to be constructed.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public class AckStructureConstructionMessage : EntityEventArgs
|
||||
@@ -72,5 +72,35 @@ namespace Content.Shared.Construction
|
||||
GhostId = ghostId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent client -> server to request a specific construction guide.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public class RequestConstructionGuide : EntityEventArgs
|
||||
{
|
||||
public readonly string ConstructionId;
|
||||
|
||||
public RequestConstructionGuide(string constructionId)
|
||||
{
|
||||
ConstructionId = constructionId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent server -> client as a response to a <see cref="RequestConstructionGuide"/> net message.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public class ResponseConstructionGuide : EntityEventArgs
|
||||
{
|
||||
public readonly string ConstructionId;
|
||||
public readonly ConstructionGuide Guide;
|
||||
|
||||
public ResponseConstructionGuide(string constructionId, ConstructionGuide guide)
|
||||
{
|
||||
ConstructionId = constructionId;
|
||||
Guide = guide;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Content.Shared.Construction.Steps
|
||||
{
|
||||
[DataField("name")] public string Name { get; private set; } = string.Empty;
|
||||
|
||||
[DataField("icon")] public SpriteSpecifier Icon { get; private set; } = SpriteSpecifier.Invalid;
|
||||
[DataField("icon")] public SpriteSpecifier? Icon { get; private set; } = null;
|
||||
|
||||
public override void DoExamine(ExaminedEvent examinedEvent)
|
||||
{
|
||||
@@ -18,5 +18,15 @@ namespace Content.Shared.Construction.Steps
|
||||
|
||||
examinedEvent.Message.AddMarkup(Loc.GetString("construction-insert-arbitrary-entity", ("stepName", Name)));
|
||||
}
|
||||
|
||||
public override ConstructionGuideEntry GenerateGuideEntry()
|
||||
{
|
||||
return new ConstructionGuideEntry()
|
||||
{
|
||||
Localization = "construction-presenter-arbitrary-step",
|
||||
Arguments = new (string, object)[]{("name", Name)},
|
||||
Icon = Icon,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,6 @@ namespace Content.Shared.Construction.Steps
|
||||
public IReadOnlyList<IGraphAction> Completed => _completed;
|
||||
|
||||
public abstract void DoExamine(ExaminedEvent examinedEvent);
|
||||
public abstract ConstructionGuideEntry GenerateGuideEntry();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Construction.Steps
|
||||
{
|
||||
@@ -14,16 +15,16 @@ namespace Content.Shared.Construction.Steps
|
||||
{
|
||||
// TODO: Make this use the material system.
|
||||
// TODO TODO: Make the material system not shit.
|
||||
[DataField("material")] public string MaterialPrototypeId { get; } = "Steel";
|
||||
[DataField("material", required:true, customTypeSerializer:typeof(PrototypeIdSerializer<StackPrototype>))]
|
||||
public string MaterialPrototypeId { get; } = "Steel";
|
||||
|
||||
[DataField("amount")] public int Amount { get; } = 1;
|
||||
|
||||
public StackPrototype MaterialPrototype =>
|
||||
IoCManager.Resolve<IPrototypeManager>().Index<StackPrototype>(MaterialPrototypeId);
|
||||
|
||||
public override void DoExamine(ExaminedEvent examinedEvent)
|
||||
{
|
||||
examinedEvent.Message.AddMarkup(Loc.GetString("construction-insert-material-entity", ("amount", Amount), ("materialName", MaterialPrototype.Name)));
|
||||
var material = IoCManager.Resolve<IPrototypeManager>().Index<StackPrototype>(MaterialPrototypeId);
|
||||
|
||||
examinedEvent.Message.AddMarkup(Loc.GetString("construction-insert-material-entity", ("amount", Amount), ("materialName", material.Name)));
|
||||
}
|
||||
|
||||
public override bool EntityValid(IEntity entity)
|
||||
@@ -40,5 +41,17 @@ namespace Content.Shared.Construction.Steps
|
||||
|
||||
return stack != null;
|
||||
}
|
||||
|
||||
public override ConstructionGuideEntry GenerateGuideEntry()
|
||||
{
|
||||
var material = IoCManager.Resolve<IPrototypeManager>().Index<StackPrototype>(MaterialPrototypeId);
|
||||
|
||||
return new ConstructionGuideEntry()
|
||||
{
|
||||
Localization = "construction-presenter-material-step",
|
||||
Arguments = new (string, object)[]{("amount", Amount), ("material", material.Name)},
|
||||
Icon = material.Icon,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,5 +35,17 @@ namespace Content.Shared.Construction.Steps
|
||||
examinedEvent.PushMarkup(Loc.GetString("construction-use-tool-entity", ("toolName", Loc.GetString(quality.ToolName))));
|
||||
|
||||
}
|
||||
|
||||
public override ConstructionGuideEntry GenerateGuideEntry()
|
||||
{
|
||||
var quality = IoCManager.Resolve<IPrototypeManager>().Index<ToolQualityPrototype>(Tool);
|
||||
|
||||
return new ConstructionGuideEntry()
|
||||
{
|
||||
Localization = "construction-presenter-tool-step",
|
||||
Arguments = new (string, object)[]{("tool", quality.ToolName)},
|
||||
Icon = quality.Icon,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user