예제 #1
0
 public void AddGuardianWhoMentionsThis(GuardianID guardian)
 {
     GuardianID[] NewMentioners = new GuardianID[GuardiansWhoMentionThis.Length + 1];
     for (int i = 0; i < GuardiansWhoMentionThis.Length; i++)
     {
         NewMentioners[i] = GuardiansWhoMentionThis[i];
     }
     NewMentioners[GuardiansWhoMentionThis.Length] = guardian;
     GuardiansWhoMentionThis = NewMentioners;
 }
예제 #2
0
 public static bool HasShop(GuardianID ID)
 {
     foreach (GuardianShop shop in Shops)
     {
         if (ID.ID == shop.OwnerID && ID.ModID == shop.OwnerModID)
         {
             return(true);
         }
     }
     return(false);
 }
예제 #3
0
 public static GuardianShop GetShop(GuardianID ID)
 {
     foreach (GuardianShop shop in Shops)
     {
         if (ID.ID == shop.OwnerID && ID.ModID == shop.OwnerModID)
         {
             return(shop);
         }
     }
     return(null);
 }
예제 #4
0
 public static bool HasFeatToMention(GuardianID id)
 {
     foreach (FeatMentioning feat in Feats)
     {
         if (feat.GuardianMentionsThis(id))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #5
0
 public bool GuardianMentionsThis(GuardianID guardian)
 {
     foreach (GuardianID g in GuardiansWhoMentionThis)
     {
         if (g.IsSameID(guardian))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #6
0
        public static GuardianID[] GetGuardiansInTheWorld(GuardianID IgnoredID = null)
        {
            List <GuardianID> guardians = new List <GuardianID>();

            foreach (int guardian in MainMod.ActiveGuardians.Keys)
            {
                if (IgnoredID == null || !MainMod.ActiveGuardians[guardian].MyID.IsSameID(IgnoredID))
                {
                    guardians.Add(MainMod.ActiveGuardians[guardian].MyID);
                }
            }
            return(guardians.ToArray());
        }
예제 #7
0
        public static void AddFeat(FeatMentioning.FeatType feat, string PlayerName, string SubjectName = "", float FeatDurationDays = 8, float ImportanceLevel = 0, GuardianID[] GuardiansWhoMentionThis = null)
        {
            if (GuardiansWhoMentionThis == null)
            {
                GuardiansWhoMentionThis = new GuardianID[0];
            }
            uint Duration = (uint)(FeatDurationDays * (60 * 60 * 24));

            foreach (FeatMentioning f in Feats)
            {
                if (f.type == feat && f.PlayerName == PlayerName)
                {
                    bool Skip = false;
                    foreach (GuardianID g in GuardiansWhoMentionThis)
                    {
                        if (!f.GuardianMentionsThis(g))
                        {
                            if (feat == FeatMentioning.FeatType.MentionPlayer)
                            {
                                Skip = true;
                                break;
                            }
                            f.AddGuardianWhoMentionsThis(g);
                        }
                    }
                    if (Skip)
                    {
                        continue;
                    }
                    if (f.Importance <= ImportanceLevel)
                    {
                        f.FeatSubject = SubjectName;
                        f.Importance  = ImportanceLevel;
                    }
                    if (f.FeatSubject == SubjectName && f.FeatDurationInGameDays < Duration)
                    {
                        f.FeatDurationInGameDays = Duration;
                    }
                    return;
                }
            }
            FeatMentioning newFeat = new FeatMentioning();

            newFeat.type                    = feat;
            newFeat.PlayerName              = PlayerName;
            newFeat.FeatSubject             = SubjectName;
            newFeat.FeatDurationInGameDays  = Duration;
            newFeat.Importance              = ImportanceLevel;
            newFeat.GuardiansWhoMentionThis = GuardiansWhoMentionThis;
            Feats.Add(newFeat);
        }
예제 #8
0
 public GuardianData(int ID = -1, string ModID = "")
 {
     if (Main.rand == null)
     {
         Main.rand = new Terraria.Utilities.UnifiedRandom();
     }
     request = new RequestData(this);
     request.SetRequestOnCooldown(true);
     if (ID != -1)
     {
         this.ID = ID;
         if (ModID == "")
         {
             ModID = MainMod.mod.Name;
         }
         this.ModID = ModID;
         MyID       = new GuardianID(ID, ModID);
         PickedName = (byte)Main.rand.Next(Base.PossibleNames.Length);
     }
     for (int e = 0; e < Equipments.Length; e++)
     {
         Equipments[e] = new Item();
     }
     for (int i = 0; i < Inventory.Length; i++)
     {
         Inventory[i] = new Item();
     }
     while (SkillList.Count < Enum.GetValues(typeof(GuardianSkills.SkillTypes)).Length)
     {
         SkillList.Add(new GuardianSkills()
         {
             skillType = (GuardianSkills.SkillTypes)SkillList.Count
         });
     }
     if (ID != -1)
     {
         int Slot = 0;
         foreach (GuardianBase.ItemPair i in Base.InitialItems)
         {
             Inventory[Slot].SetDefaults(i.ItemID, true);
             Inventory[Slot].stack = i.Stack;
             Slot++;
         }
         tactic = Base.DefaultTactic;
     }
 }
예제 #9
0
        public static FeatMentioning GetAFeatToMention(GuardianID guardian, string SpeakerPlayer)
        {
            List <FeatMentioning> feats = new List <FeatMentioning>();

            foreach (FeatMentioning feat in Feats)
            {
                if (feat.GuardiansWhoMentionThis.Length == 0 || feat.GuardianMentionsThis(guardian))
                {
                    if (feat.PlayerName != SpeakerPlayer)
                    {
                        feats.Add(feat);
                    }
                }
            }
            if (feats.Count == 0)
            {
                return(null);
            }
            return(feats[Main.rand.Next(feats.Count)]);
        }
예제 #10
0
 public bool IsSameID(GuardianID g)
 {
     return(g.ID == ID && g.ModID == ModID);
 }
예제 #11
0
 public bool IsSameAs(GuardianID GiD)
 {
     return(IsSameAs(GiD.ID, GiD.ModID));
 }