public virtual void AddPuppet(Civilization civ, IPuppetLevel puppetLevel)
 {
     civ.Master?._puppets.Remove(civ);
     civ.Master       = this;
     civ._puppetLevel = puppetLevel.Clone();
     _puppets.Add(civ);
 }
Ejemplo n.º 2
0
 protected PuppetLevel(IPuppetLevel parent)
 {
     if (parent is PuppetLevel level)
     {
         Init(level.Data.Head);
     }
     else
     {
         var data = (PuppetLevelData)parent;
         Init(data.Head ?? (IPuppetLevel)data);
     }
 }
Ejemplo n.º 3
0
        public T GetSpecialised <T>(bool create) where T : PuppetLevel, new()
        {
            if (this is T thisT)
            {
                return(thisT);
            }
            IPuppetLevel tmp = Data.Head;

            while (tmp is PuppetLevel)
            {
                if (tmp is T result)
                {
                    return(result);
                }
                tmp = ((PuppetLevel)tmp).Parent;
            }
            return(create ? (T) new T().Init(Data.Head) : null);
        }
Ejemplo n.º 4
0
        protected PuppetLevel Init(IPuppetLevel parent)
        {
            if (Parent != null)
            {
                throw new InvalidOperationException("Cannot be initialized twice");
            }
            var tmp = parent;

            while (tmp is PuppetLevel casted)
            {
                if (tmp.GetType().IsAssignableFrom(GetType()))
                {
                    throw new ArgumentException("All parents must be of different type");
                }
                tmp = casted.Parent;
            }
            Parent    = parent;
            Data      = (PuppetLevelData)tmp;
            Data.Head = this;
            return(this);
        }
 public virtual void MakeIndependent()
 {
     Master?._puppets.Remove(this);
     _puppetLevel = null;
     Master       = null;
 }
 public PuppetLevelAddition2(IPuppetLevel parent, bool addition2 = false) : base(parent)
 {
     Addition2 = addition2;
 }
Ejemplo n.º 7
0
 public PuppetLevelAddition1(IPuppetLevel parent, bool addition1 = false) : base(parent)
 {
     Addition1 = addition1;
 }
 public PuppetLevelAddition3(IPuppetLevel parent, bool addition3 = false) : base(parent)
 {
     Addition3 = addition3;
 }