From 44f4c1726623e4d3a54d2de4b63284b17f83afa2 Mon Sep 17 00:00:00 2001 From: Tornado Tech <54727692+Tornado-Technology@users.noreply.github.com> Date: Thu, 6 Mar 2025 18:22:01 +1000 Subject: [PATCH] refactor: Orthographic and obsolete in Knowledge --- .../_CP14/Knowledge/CP14KnowledgeSystem.cs | 16 ++++++++-------- .../Components/CP14AutoAddKnowledgeComponent.cs | 5 +++-- .../CP14KnowledgeLearningSourceComponent.cs | 2 +- .../CP14KnowledgePaperTextComponent.cs | 8 +++----- .../Components/CP14KnowledgeStorageComponent.cs | 4 ++-- .../Prototypes/CP14KnowledgePrototype.cs | 9 ++++----- .../_CP14/Knowledge/SharedCP14KnowledgeSystem.cs | 8 ++++---- 7 files changed, 25 insertions(+), 27 deletions(-) diff --git a/Content.Server/_CP14/Knowledge/CP14KnowledgeSystem.cs b/Content.Server/_CP14/Knowledge/CP14KnowledgeSystem.cs index 4e867f5310..e632be9614 100644 --- a/Content.Server/_CP14/Knowledge/CP14KnowledgeSystem.cs +++ b/Content.Server/_CP14/Knowledge/CP14KnowledgeSystem.cs @@ -55,7 +55,7 @@ public sealed partial class CP14KnowledgeSystem : SharedCP14KnowledgeSystem private void AddKnowledgeLearningVerb(Entity ent, ref GetVerbsEvent args) { var user = args.User; - foreach (var knowledge in ent.Comp.Knowledges) + foreach (var knowledge in ent.Comp.Knowledge) { if (!_proto.TryIndex(knowledge, out var indexedKnowledge)) continue; @@ -91,7 +91,7 @@ public sealed partial class CP14KnowledgeSystem : SharedCP14KnowledgeSystem return; //Remove knowledge - foreach (var knowledge in ent.Comp.Knowledges) + foreach (var knowledge in ent.Comp.Knowledge) { if (!_proto.TryIndex(knowledge, out var indexedKnowledge)) continue; @@ -112,7 +112,7 @@ public sealed partial class CP14KnowledgeSystem : SharedCP14KnowledgeSystem //Add knowledge foreach (var knowledge in _proto.EnumeratePrototypes()) { - if (ent.Comp.Knowledges.Contains(knowledge)) + if (ent.Comp.Knowledge.Contains(knowledge)) continue; args.Verbs.Add(new Verb() @@ -147,7 +147,7 @@ public sealed partial class CP14KnowledgeSystem : SharedCP14KnowledgeSystem if (!_proto.TryIndex(proto, out var indexedKnowledge)) return false; - if (knowledgeStorage.Knowledges.Contains(proto)) + if (knowledgeStorage.Knowledge.Contains(proto)) return false; foreach (var dependency in indexedKnowledge.Dependencies) @@ -214,7 +214,7 @@ public sealed partial class CP14KnowledgeSystem : SharedCP14KnowledgeSystem LogType.Mind, LogImpact.Medium, $"{EntityManager.ToPrettyString(uid):player} learned new knowledge: {Loc.GetString(indexedKnowledge.Name)}"); - return knowledgeStorage.Knowledges.Add(proto); + return knowledgeStorage.Knowledge.Add(proto); } public bool TryForgotKnowledge(EntityUid uid, ProtoId proto, bool silent = false) @@ -222,13 +222,13 @@ public sealed partial class CP14KnowledgeSystem : SharedCP14KnowledgeSystem if (!TryComp(uid, out var knowledgeStorage)) return false; - if (!knowledgeStorage.Knowledges.Contains(proto)) + if (!knowledgeStorage.Knowledge.Contains(proto)) return false; if (!_proto.TryIndex(proto, out var indexedKnowledge)) return false; - knowledgeStorage.Knowledges.Remove(proto); + knowledgeStorage.Knowledge.Remove(proto); if (_mind.TryGetMind(uid, out var mind, out var mindComp) && mindComp.Session is not null) { @@ -264,6 +264,6 @@ public sealed partial class CP14KnowledgeSystem : SharedCP14KnowledgeSystem if (!TryComp(entity, out var knowledgeComp)) return; - RaiseNetworkEvent(new CP14KnowledgeInfoEvent(GetNetEntity(entity),knowledgeComp.Knowledges), args.SenderSession); + RaiseNetworkEvent(new CP14KnowledgeInfoEvent(GetNetEntity(entity),knowledgeComp.Knowledge), args.SenderSession); } } diff --git a/Content.Shared/_CP14/Knowledge/Components/CP14AutoAddKnowledgeComponent.cs b/Content.Shared/_CP14/Knowledge/Components/CP14AutoAddKnowledgeComponent.cs index 3fcb3e7976..39aa528229 100644 --- a/Content.Shared/_CP14/Knowledge/Components/CP14AutoAddKnowledgeComponent.cs +++ b/Content.Shared/_CP14/Knowledge/Components/CP14AutoAddKnowledgeComponent.cs @@ -4,11 +4,12 @@ using Robust.Shared.Prototypes; namespace Content.Shared._CP14.Knowledge.Components; /// -/// The ability to add a skill to an entity and quickly teach it some skills +/// The ability to add a to an entity +/// and quickly teach it some skills. /// [RegisterComponent, Access(typeof(SharedCP14KnowledgeSystem))] public sealed partial class CP14AutoAddKnowledgeComponent : Component { [DataField] - public List> Knowledge = new(); + public List> Knowledge = []; } diff --git a/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgeLearningSourceComponent.cs b/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgeLearningSourceComponent.cs index 23af4f2cb9..065f19a0dc 100644 --- a/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgeLearningSourceComponent.cs +++ b/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgeLearningSourceComponent.cs @@ -10,7 +10,7 @@ namespace Content.Shared._CP14.Knowledge.Components; public sealed partial class CP14KnowledgeLearningSourceComponent : Component { [DataField, ViewVariables(VVAccess.ReadOnly)] - public HashSet> Knowledges { get; private set; } = new(); + public HashSet> Knowledge { get; private set; } = []; [DataField] public TimeSpan DoAfter = TimeSpan.FromSeconds(5f); diff --git a/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgePaperTextComponent.cs b/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgePaperTextComponent.cs index 7e5f291dc5..a97ce508ec 100644 --- a/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgePaperTextComponent.cs +++ b/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgePaperTextComponent.cs @@ -1,10 +1,8 @@ - namespace Content.Shared._CP14.Knowledge.Components; /// -/// automatically generates content for PaperComponent, based on the knowledge that can be learnt from this object +/// Automatically generates content for PaperComponent, +/// based on the knowledge that can be learnt from this object. /// [RegisterComponent, Access(typeof(SharedCP14KnowledgeSystem))] -public sealed partial class CP14KnowledgePaperTextComponent : Component -{ -} +public sealed partial class CP14KnowledgePaperTextComponent : Component; diff --git a/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgeStorageComponent.cs b/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgeStorageComponent.cs index cd5605affa..94aeace471 100644 --- a/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgeStorageComponent.cs +++ b/Content.Shared/_CP14/Knowledge/Components/CP14KnowledgeStorageComponent.cs @@ -4,11 +4,11 @@ using Robust.Shared.Prototypes; namespace Content.Shared._CP14.Knowledge.Components; /// -/// a list of skills learned by this entity +/// A list of learned by this entity. /// [RegisterComponent, Access(typeof(SharedCP14KnowledgeSystem))] public sealed partial class CP14KnowledgeStorageComponent : Component { [DataField, ViewVariables(VVAccess.ReadOnly)] - public HashSet> Knowledges { get; private set; } = new(); + public HashSet> Knowledge { get; private set; } = []; } diff --git a/Content.Shared/_CP14/Knowledge/Prototypes/CP14KnowledgePrototype.cs b/Content.Shared/_CP14/Knowledge/Prototypes/CP14KnowledgePrototype.cs index 9380c8c40d..4dd19ef81e 100644 --- a/Content.Shared/_CP14/Knowledge/Prototypes/CP14KnowledgePrototype.cs +++ b/Content.Shared/_CP14/Knowledge/Prototypes/CP14KnowledgePrototype.cs @@ -8,19 +8,18 @@ namespace Content.Shared._CP14.Knowledge.Prototypes; [Prototype("CP14Knowledge")] public sealed partial class CP14KnowledgePrototype : IPrototype { - [ViewVariables] [IdDataField] public string ID { get; private set; } = default!; [DataField(required: true)] - public LocId Name { get; private set; } = default!; + public LocId Name { get; private set; } [DataField] - public LocId Desc{ get; private set; } = default!; + public LocId Desc { get; private set; } /// - /// to study this knowledge, other knowledge on which it is based may be necessary. + /// To study this knowledge, other knowledge on which it is based may be necessary. /// [DataField] - public HashSet> Dependencies = new(); + public HashSet> Dependencies = []; } diff --git a/Content.Shared/_CP14/Knowledge/SharedCP14KnowledgeSystem.cs b/Content.Shared/_CP14/Knowledge/SharedCP14KnowledgeSystem.cs index 063ee84e84..2d6f0ef7d5 100644 --- a/Content.Shared/_CP14/Knowledge/SharedCP14KnowledgeSystem.cs +++ b/Content.Shared/_CP14/Knowledge/SharedCP14KnowledgeSystem.cs @@ -26,13 +26,13 @@ public abstract partial class SharedCP14KnowledgeSystem : EntitySystem return; if (!TryComp(ent, out var knowledge)) return; - if (knowledge.Knowledges.Count <= 0) + if (knowledge.Knowledge.Count <= 0) return; var sb = new StringBuilder(); sb.Append(Loc.GetString("cp14-knowledge-book-pre-text")); - foreach (var k in knowledge.Knowledges) + foreach (var k in knowledge.Knowledge) { if (!_proto.TryIndex(k, out var indexedKnowledge)) continue; @@ -54,7 +54,7 @@ public abstract partial class SharedCP14KnowledgeSystem : EntitySystem if (!Resolve(uid, ref knowledgeStorage, false)) return false; - if (!knowledgeStorage.Knowledges.Contains(knowledge)) + if (!knowledgeStorage.Knowledge.Contains(knowledge)) return false; var ev = new CP14KnowledgeUsedEvent(uid, knowledge, factor); @@ -72,7 +72,7 @@ public abstract partial class SharedCP14KnowledgeSystem : EntitySystem if (!Resolve(uid, ref knowledgeStorage, false)) return false; - return knowledgeStorage.Knowledges.Contains(knowledge); + return knowledgeStorage.Knowledge.Contains(knowledge); } }