Example #1
0
 public void SetHale(NetworkUser networkUser)
 {
     if (networkUser)
     {
         if (networkUsers.Contains(networkUser))
         {
             currentHale = networkUser;
             bossMemory  = new BossGroup.BossMemory()
             {
                 cachedMaster = currentHale.master,
                 cachedBody   = currentHale.GetCurrentBody()
             };
             combatSquad = new CombatSquad();
             combatSquad.AddMember(currentHale.master);
             bossGroup = new BossGroup()
             {
                 combatSquad          = this.combatSquad,
                 bestObservedName     = currentHale.userName,
                 bestObservedSubtitle = "The Boss",
             };
             bossGroup.AddBossMemory(currentHale.master);
             bossGroup.combatSquad = combatSquad;
         }
         else
         {
             Debug.LogError("Couldn't find NetworkUser" + networkUser + "in list of available NetworkUsers");
         }
     }
     else
     {
         Debug.LogError("NetworkUser " + networkUser + " does not exist!");
     }
 }
Example #2
0
        private static void CreateEclipseDoppelganger(CharacterMaster master, Xoroshiro128Plus rng)
        {
            var card = DoppelgangerSpawnCard.FromMaster(master);

            if (card is null)
            {
                return;
            }
            if (card.prefab is null)
            {
                card.prefab = MasterCatalog.GetMasterPrefab(defaultMasterIndex);
            }

            Transform spawnOnTarget;

            DirectorCore.MonsterSpawnDistance input;
            if (TeleporterInteraction.instance)
            {
                spawnOnTarget = TeleporterInteraction.instance.transform;
                input         = DirectorCore.MonsterSpawnDistance.Close;
            }
            else
            {
                spawnOnTarget = master.GetBody().coreTransform;
                input         = DirectorCore.MonsterSpawnDistance.Far;
            }
            DirectorPlacementRule directorPlacementRule = new DirectorPlacementRule
            {
                spawnOnTarget = spawnOnTarget,
                placementMode = DirectorPlacementRule.PlacementMode.NearestNode
            };

            DirectorCore.GetMonsterSpawnDistance(input, out directorPlacementRule.minDistance, out directorPlacementRule.maxDistance);
            DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest(card, directorPlacementRule, rng);

            directorSpawnRequest.teamIndexOverride     = new TeamIndex?(TeamIndex.Monster);
            directorSpawnRequest.ignoreTeamMemberLimit = true;

            CombatSquad squad = null;

            DirectorSpawnRequest directorSpawnRequest2 = directorSpawnRequest;

            directorSpawnRequest2.onSpawnedServer = DelegateHelper.Combine(directorSpawnRequest2.onSpawnedServer, (res) =>
            {
                if (squad is null)
                {
                    squad = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/Encounters/ShadowCloneEncounter")).GetComponent <CombatSquad>();
                }
                squad.AddMember(res.spawnedInstance.GetComponent <CharacterMaster>());
            });

            DirectorCore.instance.TrySpawnObject(directorSpawnRequest);

            if (squad is not null)
            {
                NetworkServer.Spawn(squad.gameObject);
            }
            UnityEngine.Object.Destroy(card);
        }
        private void BarrelInteraction_OnInteractionBegin(On.RoR2.BarrelInteraction.orig_OnInteractionBegin orig, BarrelInteraction self, Interactor activator)
        {
            if (!NetworkServer.active)
            {
                orig(self, activator);
                return;
            }

            if (IsOnVIPSelectionStage)
            {
                if (self.Networkopened)
                {
                    orig(self, activator);
                    return;
                }

                foreach (var barrel in spawnedBarrels)
                {
                    BarrelInteraction interaction = barrel.GetComponent <BarrelInteraction>();
                    if (self != interaction)
                    {
                        interaction.Networkopened = true;
                    }
                }

                AllyDetails details = self.GetComponent <AllyDetails>();
                if (details && details.ally)
                {
                    CharacterMaster summonCharacterMaster = activator.GetComponent <CharacterBody>().master;
                    CharacterMaster allyCharacterMaster   = details.ally.GetComponent <CharacterMaster>();

                    AllyMaster allyMaster = allyCharacterMaster.gameObject.AddComponent <AllyMaster>();
                    allyMaster.NameToken = "VIP";

                    GiveHelpingHand(allyCharacterMaster);
                    ApplyNormalAI(
                        details.ally.GetComponent <BaseAI>(),
                        summonCharacterMaster.GetBodyObject());

                    allies.Add(allyCharacterMaster);
                    allySquad.AddMember(allyCharacterMaster);

                    Chat.SendBroadcastChat(new Chat.SimpleChatMessage()
                    {
                        baseToken = $"<color=#{ColorUtility.ToHtmlStringRGB(Color.green)}>Protect the VIP:</color> " +
                                    $"<color=#{ColorUtility.ToHtmlStringRGB(Color.gray)}>Protect the ally at all costs.</color> " +
                                    $"<color=#{ColorUtility.ToHtmlStringRGB(Color.red)}>If it dies, you die.</color>"
                    });
                }
                else if (details && !details.ally)
                {
                    Chat.SendBroadcastChat(new Chat.SimpleChatMessage()
                    {
                        baseToken = $"<color=#{ColorUtility.ToHtmlStringRGB(Color.green)}>Protect the VIP:</color> " +
                                    $"<color=#{ColorUtility.ToHtmlStringRGB(Color.gray)}>Starting run with no ally.</color>"
                    });
                }
                else
                {
                    Debug.LogError("No details attached to barrel :( Starting normal run...");
                }

                GoToNextLevel();

                Debug.Log("Unhooking from RoR2.BarrelInteraction.OnInteractionBegin");
                On.RoR2.BarrelInteraction.OnInteractionBegin -= BarrelInteraction_OnInteractionBegin;
            }

            orig(self, activator);
        }