예제 #1
0
        public static bool ChangeDifficulty(Players.Player player, ColonyState state, string difficulty)
        {
            if (SettlersConfiguration.DifficutlyCanBeChanged)
            {
                if (!GameDifficulty.GameDifficulties.ContainsKey(difficulty))
                {
                    UnknownCommand(player, difficulty);
                    return(true);
                }

                var newDiff = GameDifficulty.GameDifficulties[difficulty];

                if (newDiff.Rank >= SettlersConfiguration.MinDifficulty.Rank)
                {
                    state.Difficulty = newDiff;
                    SettlerManager.UpdateFoodUse(state);
                    state.Difficulty.Print(player);

                    PandaChat.Send(player, "Settlers! Mod difficulty set to {0}.", ChatColor.green,
                                   state.Difficulty.Name);

                    NetworkUI.NetworkMenuManager.SendColonySettingsUI(player);
                    return(true);
                }

                NetworkUI.NetworkMenuManager.SendColonySettingsUI(player);
                PandaChat.Send(player, "The server administrator had disabled setting your difficulty below {0}.",
                               ChatColor.green, SettlersConfiguration.MinDifficulty.Name);
            }

            return(true);
        }
        private MarriedRelationship(SettlerManager sm, int value, Settler partner1, Settler partner2) : base(sm, value, partner1, GetMarriedRole(partner1), partner2, GetMarriedRole(partner2))
        {
            //Remove prior loverRelationship
            var loverRelationship =
                partner1.Relationships.FirstOrDefault(rel => rel is LoverRelationship love && love.Contains(partner2));

            if (loverRelationship != null)
            {
                partner1.Relationships.Remove(loverRelationship);
                partner2.Relationships.Remove(loverRelationship);
            }
        }
예제 #3
0
        protected Relationship(SettlerManager sm, int value, Settler settler1, RelationshipRole role1, Settler settler2,
                               RelationshipRole role2)
        {
            Value    = value;
            Settler1 = settler1;
            Role1    = role1;
            Settler2 = settler2;
            Role2    = role2;

            settler1.Relationships.Add(this);
            settler2.Relationships.Add(this);
            sm.Add(this);
        }
예제 #4
0
        private ParentChildRelationship(SettlerManager sm, int value, Settler parent, Settler child) : base(sm, value, parent, GetParentRole(parent), child, GetChildRole(child))
        {
            //Add siblings
            var currentSiblings = SiblingRelationship.GetSiblings(child);
            var actualSiblings  = GetChildren(parent).Where(c => c != child);

            foreach (var sibling in actualSiblings)
            {
                if (!currentSiblings.Contains(sibling))
                {
                    SiblingRelationship.Make(sm, 0, child, sibling);
                }
            }
        }
예제 #5
0
        public static float SpawnChance(ColonyState state)
        {
            var chance        = .3f;
            var remainingBeds = state.ColonyRef.BedTracker.CalculateTotalBedCount() - state.ColonyRef.FollowerCount;

            if (remainingBeds < 1)
            {
                chance -= 0.1f;
            }

            if (remainingBeds >= SettlerManager.MaxPerSpawn(state.ColonyRef))
            {
                chance += 0.3f;
            }
            else if (remainingBeds > SettlerManager.MIN_PERSPAWN)
            {
                chance += 0.15f;
            }

            var jobCount = state.ColonyRef.GetJobCounts().Select(kvp => kvp.Value.AvailableCount).Sum();

            if (jobCount > SettlerManager.MaxPerSpawn(state.ColonyRef))
            {
                chance += 0.4f;
            }
            else if (jobCount > SettlerManager.MIN_PERSPAWN)
            {
                chance += 0.1f;
            }
            else
            {
                chance -= 0.2f;
            }

            chance += SettlerChance.GetSettlerChance(state.ColonyRef);

            if (state.Difficulty != GameDifficulty.Normal)
            {
                if (state.ColonyRef.InSiegeMode ||
                    state.ColonyRef.LastSiegeModeSpawn != 0 &&
                    Time.SecondsSinceStartDouble - state.ColonyRef.LastSiegeModeSpawn > TimeSpan.FromMinutes(5).TotalSeconds)
                {
                    chance -= 0.4f;
                }
            }

            return(chance);
        }
예제 #6
0
        public bool TryDoCommand(Players.Player player, string chat)
        {
            if (player == null || player.ID == NetworkID.Server ||
                !PermissionsManager.CheckAndWarnPermission(player,
                                                           new PermissionsManager.Permission(GameLoader.NAMESPACE +
                                                                                             ".Permissions.Archive")))
            {
                return(true);
            }

            foreach (var p in Players.PlayerDatabase.ValuesAsList)
            {
                SettlerManager.SaveOffline(p);
            }

            return(true);
        }
 public static void Make(SettlerManager sm, int value, Settler settler1, Settler settler2)
 {
     new AcquaintanceRelationship(sm, value, settler1, settler2);
 }
예제 #8
0
 public override void ResearchComplete(object sender, ResearchCompleteEventArgs e)
 {
     SettlerManager.ApplyJobCooldownsToNPCs(e.Manager.Colony);
 }
        public static void BuildSettlerDetailMenu(ButtonPressCallbackData data, KeyValuePair <string, JobCounts> jobKvp, global::Jobs.IJob job)
        {
            var         inv  = Entities.SettlerInventory.GetSettlerInventory(job.NPC);
            NetworkMenu menu = new NetworkMenu();

            menu.LocalStorage.SetAs("header", _localizationHelper.LocalizeOrDefault("Colonist", data.Player) + " " + inv.SettlerName + " " + _localizationHelper.LocalizeOrDefault("Details", data.Player));
            menu.Width  = 1000;
            menu.Height = 600;

            menu.Items.Add(new Line(UnityEngine.Color.black));
            menu.Items.Add(new ButtonCallback(jobKvp.Key + ".JobDetailsButton", new LabelData(_localizationHelper.GetLocalizationKey("Back"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)));
            menu.Items.Add(new Line(UnityEngine.Color.black));

            menu.Items.Add(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Stats"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 24)));
            menu.Items.Add(new HorizontalSplit(new Label(new LabelData(_localizationHelper.GetLocalizationKey("SkillProcChance"), UnityEngine.Color.black)),
                                               new Label(new LabelData((inv.GetSkillModifier() * 100) + "%", UnityEngine.Color.black))));
            menu.Items.Add(new Label(new LabelData(_localizationHelper.GetLocalizationKey("SkillProcChanceDesc"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 13)));
            SettlerManager.GetSkillInformation(job.NPC, out var nextLevel, out var itt, out var allSkill);
            menu.Items.Add(new HorizontalSplit(new Label(new LabelData(_localizationHelper.GetLocalizationKey("ToNextSkillUp"), UnityEngine.Color.black)),
                                               new Label(new LabelData((nextLevel - itt).ToString(), UnityEngine.Color.black))));

            foreach (var statItem in inv.Stats)
            {
                if (ItemTypes.IndexLookup.TryGetIndex(statItem.Key, out var itemIndex))
                {
                    menu.Items.Add(new HorizontalSplit(new Label(new LabelData(statItem.Key, UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 18, LabelData.ELocalizationType.Type)),
                                                       new Label(new LabelData(statItem.Value.ToString(), UnityEngine.Color.black))));
                }
                else
                {
                    menu.Items.Add(new HorizontalSplit(new Label(new LabelData(statItem.Key, UnityEngine.Color.black)),
                                                       new Label(new LabelData(statItem.Value.ToString(), UnityEngine.Color.black))));
                }
            }

            menu.Items.Add(new Line(UnityEngine.Color.black));
            menu.Items.Add(new Label(new LabelData(_localizationHelper.GetLocalizationKey("BonusProcs"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 20)));

            var procItemsHeader = new List <ValueTuple <IItem, int> >();

            procItemsHeader.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Item"), UnityEngine.Color.black)), 150));
            procItemsHeader.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData("", UnityEngine.Color.black)), 150));
            procItemsHeader.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Count"), UnityEngine.Color.black)), 150));
            menu.Items.Add(new HorizontalRow(procItemsHeader));

            if (inv.BonusProcs.Count == 0)
            {
                menu.Items.Add(new Label(new LabelData(_localizationHelper.GetLocalizationKey("NoneYet"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 20)));
            }

            foreach (var proc in inv.BonusProcs)
            {
                var procItems = new List <ValueTuple <IItem, int> >();
                procItems.Add(ValueTuple.Create <IItem, int>(new ItemIcon(proc.Key), 150));
                procItems.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(ItemTypes.GetType(proc.Key).Name, UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 18, LabelData.ELocalizationType.Type)), 150));
                procItems.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData("x " + proc.Value, UnityEngine.Color.black)), 150));
                menu.Items.Add(new HorizontalRow(procItems));
            }

            menu.Items.Add(new Line(UnityEngine.Color.black));
            menu.Items.Add(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Equiptment"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 24)));
            List <ValueTuple <IItem, int> > wep = new List <ValueTuple <IItem, int> >();

            wep.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey("Weapon"), UnityEngine.Color.black)), 200));
            wep.Add(ValueTuple.Create <IItem, int>(new ItemIcon(inv.Weapon.Id), 200));

            if (Weapons.WeaponFactory.WeaponLookup.TryGetValue(inv.Weapon.Id, out var wepItem))
            {
                wep.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(wepItem.name, UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 18, LabelData.ELocalizationType.Type)), 200));
                wep.Add(ValueTuple.Create <IItem, int>(new ButtonCallback(jobKvp.Key + ".wep." + job.NPC.ID + ".AddEquiptmentButton", new LabelData(_localizationHelper.GetLocalizationKey("Swap"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 200));
                wep.Add(ValueTuple.Create <IItem, int>(new ButtonCallback(jobKvp.Key + ".wep." + job.NPC.ID + ".RemoveEquiptmentButton", new LabelData(_localizationHelper.GetLocalizationKey("Remove"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 200));
            }
            else
            {
                wep.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData("", UnityEngine.Color.black)), 200));
                wep.Add(ValueTuple.Create <IItem, int>(new ButtonCallback(jobKvp.Key + ".wep." + job.NPC.ID + ".AddEquiptmentButton", new LabelData(_localizationHelper.GetLocalizationKey("Add"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 200));
            }

            menu.Items.Add(new HorizontalRow(wep));

            foreach (var armor in inv.Armor)
            {
                List <ValueTuple <IItem, int> > items = new List <ValueTuple <IItem, int> >();
                items.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(_localizationHelper.GetLocalizationKey(armor.Key.ToString()), UnityEngine.Color.black)), 200));
                items.Add(ValueTuple.Create <IItem, int>(new ItemIcon(armor.Value.Id), 200));

                if (Armor.ArmorFactory.ArmorLookup.TryGetValue(armor.Value.Id, out var arm))
                {
                    items.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData(arm.name, UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleLeft, 18, LabelData.ELocalizationType.Type)), 200));
                    items.Add(ValueTuple.Create <IItem, int>(new ButtonCallback(jobKvp.Key + "." + armor.Key + ".arm." + job.NPC.ID + ".AddEquiptmentButton", new LabelData(_localizationHelper.GetLocalizationKey("Swap"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 200));
                    items.Add(ValueTuple.Create <IItem, int>(new ButtonCallback(jobKvp.Key + "." + armor.Key + ".arm." + job.NPC.ID + ".RemoveEquiptmentButton", new LabelData(_localizationHelper.GetLocalizationKey("Remove"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 200));
                }
                else
                {
                    items.Add(ValueTuple.Create <IItem, int>(new Label(new LabelData("", UnityEngine.Color.black)), 200));
                    items.Add(ValueTuple.Create <IItem, int>(new ButtonCallback(jobKvp.Key + "." + armor.Key + ".arm." + job.NPC.ID + ".AddEquiptmentButton", new LabelData(_localizationHelper.GetLocalizationKey("Add"), UnityEngine.Color.black, UnityEngine.TextAnchor.MiddleCenter)), 200));
                }

                menu.Items.Add(new HorizontalRow(items));
            }


            NetworkMenuManager.SendServerPopup(data.Player, menu);
        }
예제 #10
0
        public static bool EvaluateSettlers(ColonyState state)
        {
            var update = false;

            if (state.SettlersEnabled != SettlersState.Disabled && state.ColonyRef.OwnerIsOnline())
            {
                if (state.NextGenTime == 0)
                {
                    state.NextGenTime = TimeCycle.TotalHours + Random.Next(8, 16);
                }

                if (TimeCycle.TotalHours > state.NextGenTime && state.ColonyRef.FollowerCount >= MAX_BUYABLE)
                {
                    var chance =
                        state.ColonyRef.TemporaryData.GetAsOrDefault(GameLoader.NAMESPACE + ".SettlerChance", 0f) +
                        state.Difficulty.GetorDefault("AdditionalChance", 0);

                    chance += SettlerEvaluation.SpawnChance(state);

                    var rand = Random.NextFloat();

                    if (chance > rand)
                    {
                        var addCount = Math.Floor(SettlerManager.MaxPerSpawn(state.ColonyRef) * chance);

                        // if we lost alot of colonists add extra to help build back up.
                        if (state.ColonyRef.FollowerCount < state.HighestColonistCount)
                        {
                            var diff = state.HighestColonistCount - state.ColonyRef.FollowerCount;
                            addCount += Math.Floor(diff * .25);
                        }

                        try
                        {
                            var skillChance = state.ColonyRef.TemporaryData.GetAsOrDefault(GameLoader.NAMESPACE + ".SkilledLaborer", 0f) + SkilledSettlerChance.GetSkilledSettlerChance(state.ColonyRef);
                            var numbSkilled = 0;
                            rand = Random.NextFloat();

                            try
                            {
                                if (skillChance > rand)
                                {
                                    numbSkilled = Pipliz.Random.Next(1,
                                                                     2 + Pipliz.Math.RoundToInt(state.ColonyRef.TemporaryData.GetAsOrDefault(GameLoader.NAMESPACE + ".NumberSkilledLaborer", 0f)));
                                }
                            }
                            catch (Exception ex)
                            {
                                SettlersLogger.Log("NumberSkilledLaborer");
                                SettlersLogger.LogError(ex);
                            }


                            if (addCount > 0)
                            {
                                if (addCount > 30)
                                {
                                    addCount = 30;
                                }

                                if (state.SettlersEnabled == SettlersState.AlwaysAccept)
                                {
                                    AddNewSettlers(addCount, numbSkilled, state);
                                }
                                else
                                {
                                    foreach (var p in state.ColonyRef.Owners)
                                    {
                                        if (p.IsConnected())
                                        {
                                            NetworkMenu menu = new NetworkMenu();
                                            menu.LocalStorage.SetAs("header", state.ColonyRef.Name + ": " + addCount + _localizationHelper.LocalizeOrDefault("NewSettlers", p));
                                            menu.Width  = 600;
                                            menu.Height = 300;

                                            menu.Items.Add(new ButtonCallback(GameLoader.NAMESPACE + ".NewSettlers." + state.ColonyRef.ColonyID + ".Accept." + addCount + "." + numbSkilled,
                                                                              new LabelData(_localizationHelper.GetLocalizationKey("Accept"),
                                                                                            UnityEngine.Color.black,
                                                                                            UnityEngine.TextAnchor.MiddleCenter)));

                                            menu.Items.Add(new ButtonCallback(GameLoader.NAMESPACE + ".NewSettlers." + state.ColonyRef.ColonyID + ".Decline",
                                                                              new LabelData(_localizationHelper.GetLocalizationKey("Decline"),
                                                                                            UnityEngine.Color.black,
                                                                                            UnityEngine.TextAnchor.MiddleCenter)));

                                            NetworkMenuManager.SendServerPopup(p, menu);
                                        }
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            SettlersLogger.Log("SkilledLaborer");
                            SettlersLogger.LogError(ex);
                        }

                        if (state.ColonyRef.FollowerCount > state.HighestColonistCount)
                        {
                            state.HighestColonistCount = state.ColonyRef.FollowerCount;
                        }
                    }


                    state.NextGenTime = TimeCycle.TotalHours + Random.Next(8, 16);

                    state.ColonyRef.SendCommonData();
                }
            }

            return(update);
        }
 public static void Make(SettlerManager sm, int value, Settler settler1, Settler settler2)
 {
     new MarriedRelationship(sm, value, settler1, settler2);
 }
예제 #12
0
 public VarskFamilyFactory(SettlerManager manager)
 {
     _manager = manager;
     _factory = new VarskFactory(manager);
 }
예제 #13
0
 public static void Make(SettlerManager sm, int value, Settler parent, Settler child)
 {
     new ParentChildRelationship(sm, value, parent, child);
 }
 public static void Make(SettlerManager sm, int value, Settler sibling1, Settler sibling2)
 {
     new SiblingRelationship(sm, 0, sibling1, sibling2);
 }
 private SiblingRelationship(SettlerManager sm, int value, Settler sibling1, Settler sibling2) : base(sm, value, sibling1, GetSiblingRole(sibling1), sibling2, GetSiblingRole(sibling2))
 {
 }
 private AcquaintanceRelationship(SettlerManager sm, int value, Settler settler1, Settler settler2) : base(sm, value, settler1, Acquaintance, settler2, Acquaintance)
 {
 }
예제 #17
0
 private static void ReducedWaste_ResearchComplete(object sender, ResearchCompleteEventArgs e)
 {
     SettlerManager.UpdateFoodUse(e.Manager.Player);
 }
예제 #18
0
 public VarskFactory(SettlerManager manager)
 {
     _manager = manager;
 }
예제 #19
0
 public void ResearchComplete(object sender, ResearchCompleteEventArgs e)
 {
     SettlerManager.ApplyJobCooldownsToNPCs(e.Manager.Colony);
     //e.Manager.Colony.TemporaryData.SetAs(Nach0ColonyBuiltIn.NpcTypes.BASICSTONEMASON, e.Research.Value);
 }
예제 #20
0
 public static void Make(SettlerManager sm, int value, Settler lover1, Settler lover2)
 {
     new LoverRelationship(sm, value, lover1, lover2);
 }
예제 #21
0
 private LoverRelationship(SettlerManager sm, int value, Settler lover1, Settler lover2) : base(sm, value, lover1, Lover, lover2, Lover)
 {
 }
예제 #22
0
 public void ResearchComplete(object sender, ResearchCompleteEventArgs e)
 {
     SettlerManager.UpdateFoodUse(ColonyState.GetColonyState(e.Manager.Colony));
 }