Basis for the job system (#434)
* Add basic yaml Jobs file * Add Job Prototype * Rename Jobs to Job * Remove BaseJob * Add the Job class child of Role * Add code for spawning as an assistant. Not actually working, the job prototype can't be found. * Fix role instead of job left in yaml * Add starting gear support for job and the starting gear for assistant as an exemple * Link job with starting gear in yaml * Better naming and some error handling * Tweak error handling
This commit is contained in:
committed by
Pieter-Jan Briers
parent
480d3b26c4
commit
447db2e458
27
Content.Shared/Jobs/JobPrototype.cs
Normal file
27
Content.Shared/Jobs/JobPrototype.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Shared.Jobs
|
||||
{
|
||||
[Prototype("job")]
|
||||
public class JobPrototype : IPrototype, IIndexedPrototype
|
||||
{
|
||||
public string ID { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
|
||||
public string StartingGear { get; private set; }
|
||||
public IEnumerable<string> Department { get; private set; }
|
||||
|
||||
public void LoadFrom(YamlMappingNode mapping)
|
||||
{
|
||||
ID = mapping.GetNode("id").AsString();
|
||||
Name = mapping.GetNode("name").ToString();
|
||||
StartingGear = mapping.GetNode("startingGear").ToString();
|
||||
Department = mapping.GetNode("department").AllNodes.Select(i => i.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Content.Shared/Jobs/StartingGearPrototype.cs
Normal file
30
Content.Shared/Jobs/StartingGearPrototype.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Shared.Jobs
|
||||
{
|
||||
[Prototype("startingGear")]
|
||||
public class StartingGearPrototype : IPrototype, IIndexedPrototype
|
||||
{
|
||||
private string _id;
|
||||
private Dictionary<string, string> _equipment;
|
||||
|
||||
[ViewVariables]
|
||||
public string ID => _id;
|
||||
|
||||
[ViewVariables]
|
||||
public Dictionary<string, string> Equipment => _equipment;
|
||||
|
||||
public void LoadFrom(YamlMappingNode mapping)
|
||||
{
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
|
||||
serializer.DataField(ref _id, "id", string.Empty);
|
||||
serializer.DataField(ref _equipment, "equipment", new Dictionary<string, string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user