Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
FactionManager.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using Newtonsoft.Json;
3using UnityEngine;
4
5public class FactionManager : EClass
6{
7 [JsonProperty]
8 public Dictionary<string, Faction> dictAll = new Dictionary<string, Faction>();
9
10 [JsonProperty]
11 public new Faction Home;
12
13 [JsonProperty]
14 public new Faction Wilds;
15
16 [JsonProperty]
18
19 [JsonProperty]
21
22 [JsonProperty]
24
25 [JsonProperty]
27
28 public void AssignUID(Faction s)
29 {
30 Faction faction = dictAll.TryGetValue(s.id);
31 if (faction != null)
32 {
33 Debug.LogError("exception: Faction id already exists:" + faction.id);
34 }
35 s.uid = s.id;
36 dictAll.Add(s.uid, s);
37 }
38
39 public void OnCreateGame()
40 {
41 foreach (SourceFaction.Row row in EClass.sources.factions.rows)
42 {
43 Faction.Create(row);
44 }
45 Home = Find("home");
46 Home.relation.type = FactionRelation.RelationType.Owner;
47 Wilds = Find("wilds");
48 Fighter = Find<GuildFighter>("guild_fighter");
49 Mage = Find<GuildMage>("guild_mage");
50 Thief = Find<GuildThief>("guild_thief");
51 Merchant = Find<GuildMerchant>("guild_merchant");
52 }
53
54 public void OnLoad()
55 {
56 foreach (Faction value in dictAll.Values)
57 {
58 value.OnLoad();
59 }
60 }
61
62 public T Find<T>(string id) where T : Faction
63 {
64 return Find(id) as T;
65 }
66
67 public Faction Find(string id)
68 {
69 foreach (Faction value in dictAll.Values)
70 {
71 if (value.id == id)
72 {
73 return value;
74 }
75 }
76 return null;
77 }
78}
Definition: EClass.cs:5
static SourceManager sources
Definition: EClass.cs:42
GuildMerchant Merchant
new Faction Home
Faction Find(string id)
void AssignUID(Faction s)
GuildThief Thief
Dictionary< string, Faction > dictAll
GuildMage Mage
GuildFighter Fighter
new Faction Wilds
T Find< T >(string id)
string uid
Definition: FACTION.cs:130
string id
Definition: FACTION.cs:127
static Faction Create(SourceFaction.Row r)
Definition: FACTION.cs:154
void OnLoad()
Definition: FACTION.cs:170
SourceFaction factions