private static void PawnHandlerSyncer(SyncWorker sync, ref PawnSavedPositionHandler inst)
        {
            var ownerPawn = inst?.Owner;

            sync.Bind(ref ownerPawn);
            if (!sync.isWriting && ownerPawn != null)
            {
                inst = DefensivePositionsManager.Instance.GetHandlerForPawn(ownerPawn);
            }
        }
Пример #2
0
        public PawnSavedPositionHandler GetOrAddPawnHandler(Pawn pawn)
        {
            var handler = handlers.TryGetValue(pawn);

            if (handler == null)
            {
                handler = new PawnSavedPositionHandler();
                handler.AssignOwner(pawn);
                handlers.Add(pawn, handler);
            }
            return(handler);
        }
        public PawnSavedPositionHandler GetHandlerForPawn(Pawn pawn)
        {
            if (saveData == null)
            {
                throw new Exception("Cannot get handler- saveData not loaded");
            }
            var pawnId = pawn.thingIDNumber;

            if (!saveData.handlers.TryGetValue(pawnId, out PawnSavedPositionHandler handler))
            {
                handler = new PawnSavedPositionHandler();
                saveData.handlers.Add(pawnId, handler);
            }
            handler.Owner = pawn;
            return(handler);
        }