private void disconnectAllSurrogates()
 {
     foreach (var m in storedMinds)
     {
         CompSurrogateOwner cso = m.ATCompSurrogateOwner;
         if (cso != null)
         {
             cso.stopControlledSurrogate(null);
         }
     }
 }
            public static bool Listener(Pawn __instance, DamageInfo?dinfo, Hediff exactCulprit = null)
            {
                try
                {
                    if (__instance.IsSurrogateAndroid())
                    {
                        Utils.insideKillFuncSurrogate = true;

                        //Si c'est un surrogate controllé temporaire alors on le restitue a sa faction
                        CompSkyMind csm = __instance.TryGetComp <CompSkyMind>();
                        if (csm != null)
                        {
                            //Log.Message("Restitution surrogate a sa faction");
                            csm.tempHackingEnding();
                        }
                    }
                    //disconnect killed user
                    Utils.GCATPP.disconnectUser(__instance);
                    //Log.Message("YOU KILLED "+__instance.LabelCap);
                    //Is surrogate android used ?
                    if (__instance.IsSurrogateAndroid(true))
                    {
                        //Obtention controlleur
                        CompAndroidState cas = __instance.TryGetComp <CompAndroidState>();
                        if (cas == null)
                        {
                            return(true);
                        }

                        //Arret du mode de control chez le controller
                        CompSurrogateOwner cso = cas.surrogateController.TryGetComp <CompSurrogateOwner>();
                        cso.stopControlledSurrogate(__instance, false, false, true);

                        //On reset les données pour une potentiel futur resurection
                        cas.resetInternalState();
                    }


                    //Log.Message("YOU KILLED END");
                    Utils.insideKillFuncSurrogate = false;
                    return(true);
                }
                catch (Exception e)
                {
                    Log.Message("[ATPP] Pawn.Kill(Error) : " + e.Message + " - " + e.StackTrace);

                    if (__instance.IsSurrogateAndroid())
                    {
                        Utils.insideKillFuncSurrogate = false;
                    }
                    return(true);
                }
            }
Ejemplo n.º 3
0
            public static void Listener(Pawn ___pawn, DamageInfo?dinfo, Hediff hediff)
            {
                try {
                    // Deconnexion of Is surrogate android used et que appartenant au joueur ====>>>> POUR eviter les problemes de reminescence fantome de surrogates d'autres factions dans des Lord qui reste a cause du fait que le MakeDown les enleves de la liste mais le disconnect va essayer de relancer un CONNECT (dans le cadre des surrogates externes)
                    if (___pawn.IsSurrogateAndroid(true) && ___pawn.Faction.IsPlayer)
                    {
                        //Obtention controlleur
                        CompAndroidState cas = ___pawn.ATCompState;
                        if (cas == null)
                        {
                            return;
                        }

                        //Arret du mode de control chez le controller
                        CompSurrogateOwner cso = cas.surrogateController.ATCompSurrogateOwner;
                        cso.stopControlledSurrogate(null);
                    }
                }
                catch (Exception e) {
                    Log.Message("[ATPP] Pawn_HealthTracker.MakeDowned : " + e.Message + " - " + e.StackTrace);
                }
            }
            public static void Listener(Pawn victim, DamageInfo?dinfo)
            {
                try
                {
                    if (victim.IsSurrogateAndroid())
                    {
                        Utils.insideKillFuncSurrogate = true;
                    }
                    //Deconnecte le tué
                    Utils.GCATPP.disconnectUser(victim);
                    //Log.Message("YOU KILLED "+__instance.LabelCap);
                    //Is surrogate android used ?
                    if (victim.IsSurrogateAndroid(true))
                    {
                        //Obtention controlleur
                        CompAndroidState cas = victim.TryGetComp <CompAndroidState>();
                        if (cas == null)
                        {
                            return;
                        }

                        //Arret du mode de control chez le controller
                        CompSurrogateOwner cso = cas.surrogateController.TryGetComp <CompSurrogateOwner>();
                        cso.stopControlledSurrogate(victim);
                    }
                    //Log.Message("YOU KILLED END");
                    Utils.insideKillFuncSurrogate = false;
                }
                catch (Exception e)
                {
                    Log.Message("[ATPP] TaleUtility.Notify_PawnDied(Error) : " + e.Message + " - " + e.StackTrace);

                    if (victim.IsSurrogateAndroid())
                    {
                        Utils.insideKillFuncSurrogate = false;
                    }
                }
            }
Ejemplo n.º 5
0
        public void tempHackingEnding()
        {
            if (hacked != 3)
            {
                return;
            }
            //Fin du hack temporaire du surrogate on deconnecte le joueur
            Pawn cp = (Pawn)parent;

            CompAndroidState cas = cp.ATCompState;

            if (cas.surrogateController != null)
            {
                CompSurrogateOwner cso = cas.surrogateController.ATCompSurrogateOwner;
                cso.stopControlledSurrogate(cp, true);
            }

            cp.SetFaction(hackOrigFaction, null);
            //Si le surrogate été un prisonnier on le restaure en tant que tel
            if (hackWasPrisoned)
            {
                if (cp.guest != null)
                {
                    cp.guest.SetGuestStatus(Faction.OfPlayer, true);
                    if (cp.workSettings == null)
                    {
                        cp.workSettings = new Pawn_WorkSettings(cp);
                        cp.workSettings.EnableAndInitializeIfNotAlreadyInitialized();
                    }
                }
            }

            if (cp.jobs != null)
            {
                cp.jobs.StopAll();
                cp.jobs.ClearQueuedJobs();
            }
            if (cp.mindState != null)
            {
                cp.mindState.Reset(true);
            }

            PawnComponentsUtility.AddAndRemoveDynamicComponents(cp, false);
            hacked          = -1;
            hackEndGT       = -1;
            hackWasPrisoned = false;

            cp.Map.attackTargetsCache.UpdateTarget(cp);

            foreach (var p in cp.Map.mapPawns.AllPawnsSpawned)
            {
                if (p.mindState == null)
                {
                    continue;
                }

                Thing aim = p.mindState.enemyTarget;

                if (aim != null && aim is Pawn)
                {
                    //Log.Message("=>" + aim.def.defName);

                    Pawn pawnTarget = (Pawn)aim;
                    if (pawnTarget == cp)
                    {
                        if (p.jobs != null)
                        {
                            p.jobs.StopAll();
                            p.jobs.ClearQueuedJobs();
                        }
                    }
                }
            }

            Find.ColonistBar.MarkColonistsDirty();
        }