//============================================================================== // // METHODS // //============================================================================== public virtual void DeSerialize(_FactionSerialized inRawFaction) { if (GameLoop.MAIN?.FactionManager == null) { return; } #region Name if (!string.IsNullOrWhiteSpace(inRawFaction.Name)) { this._Name = inRawFaction.Name; } else { Debug.LogWarning($"Creating a {this.GetType().Name} with no name defined."); } #endregion #region ID inRawFaction.ID = inRawFaction.ID.ToLowerInvariant(); //ToDo: Regex Check Syntax if (!string.IsNullOrWhiteSpace(inRawFaction.ID)) { if (!inRawFaction.ID.StartsWith("faction.")) { inRawFaction.ID = "faction." + inRawFaction.ID; //Debug.LogError($"Cannot create Faction:'{_Name}'. Faction ID must start with 'faction.'!"); } if (!GameLoop.MAIN.FactionManager.FactionIDExists(inRawFaction.ID)) { this._ID = inRawFaction.ID; } else { Debug.LogError($"Cannot creation Faction:'{_Name}'. Faction ID:{inRawFaction.ID} already exists!"); return; } } else { Debug.LogError($"Cannot creation Faction:'{_Name}'. A unique faction ID must be provided!"); return; } #endregion }
//============================================================================== // // CONSTRUCTORS // //============================================================================== public Faction(_FactionSerialized inRawFaction) { DeSerialize(inRawFaction); }