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; }
public static bool HasShop(GuardianID ID) { foreach (GuardianShop shop in Shops) { if (ID.ID == shop.OwnerID && ID.ModID == shop.OwnerModID) { return(true); } } return(false); }
public static GuardianShop GetShop(GuardianID ID) { foreach (GuardianShop shop in Shops) { if (ID.ID == shop.OwnerID && ID.ModID == shop.OwnerModID) { return(shop); } } return(null); }
public static bool HasFeatToMention(GuardianID id) { foreach (FeatMentioning feat in Feats) { if (feat.GuardianMentionsThis(id)) { return(true); } } return(false); }
public bool GuardianMentionsThis(GuardianID guardian) { foreach (GuardianID g in GuardiansWhoMentionThis) { if (g.IsSameID(guardian)) { return(true); } } return(false); }
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()); }
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); }
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; } }
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)]); }
public bool IsSameID(GuardianID g) { return(g.ID == ID && g.ModID == ModID); }
public bool IsSameAs(GuardianID GiD) { return(IsSameAs(GiD.ID, GiD.ModID)); }