Exemplo n.º 1
0
        public void SetPriority(Pawn pawn, WorkTypeDef workTypeDef, int priority)
        {
            var index = pawnPrioritiesList.FindIndex(p => p.pawn == pawn);

            if (index == -1)
            {
                var newPawnPriorities = PawnPriorities.BuildFromCurrent(pawn);
                newPawnPriorities.SetPriority(workTypeDef, priority);
                pawnPrioritiesList.Add(newPawnPriorities);
            }
            else
            {
                pawnPrioritiesList[index].SetPriority(workTypeDef, priority);
            }
        }
Exemplo n.º 2
0
        public static FactionPriorities BuildFromCurrent(string name = "Current")
        {
            var newFactionPriorities = new FactionPriorities {
                name = name
            };

            foreach (Pawn pawn in PawnsFinder.AllMapsAndWorld_Alive)
            {
                if (pawn.Faction == Faction.OfPlayer && pawn.workSettings != null)
                {
                    newFactionPriorities.pawnPrioritiesList.Add(PawnPriorities.BuildFromCurrent(pawn));
                }
            }
            return(newFactionPriorities);
        }
        public static PawnPriorities BuildFromCurrent(Pawn pawn)
        {
            var newPriorities = new PawnPriorities();

            newPriorities.pawn         = pawn;
            newPriorities.priorityList = new List <Priority>();
            if (pawn.workSettings != null)
            {
                var disabledWorkTypes = pawn.GetDisabledWorkTypes();
                foreach (WorkTypeDef workDef in DefDatabase <WorkTypeDef> .AllDefs)
                {
                    if (!disabledWorkTypes.Contains(workDef))
                    {
                        var priority = pawn.workSettings.GetPriority(workDef);
                        newPriorities.priorityList.Add(new Priority(workDef, priority));
                    }
                }
            }
            return(newPriorities);
        }
 public bool Equals(PawnPriorities other)
 {
     return(pawn == other.pawn);
 }