Exemplo n.º 1
0
 public WatchedPlayer(PlayerWatcher watcher)
 {
     FoundActors        = new Dictionary <ulong, CharacterEquipment>(4);
     RegisteredWatchers = new HashSet <PlayerWatcher> {
         watcher
     };
 }
Exemplo n.º 2
0
    // Start is called before the first frame update
    //   This makes our prefabs and hooks up our companion script for each door.
    void Start()
    {
        // Make watchers for the triggers
        innerWatcher = innerTrigger.AddComponent <PlayerWatcher>();
        outerWatcher = outerTrigger.AddComponent <PlayerWatcher>();

        innerScript = innerDoor.GetComponent <AirlockDoor>();
        outerScript = outerDoor.GetComponent <AirlockDoor>();
    }
Exemplo n.º 3
0
        public Penumbra(DalamudPluginInterface pluginInterface)
        {
            FFXIVClientStructs.Resolver.Initialize();
            Dalamud.Initialize(pluginInterface);
            GameData.GameData.GetIdentifier(Dalamud.GameData, Dalamud.ClientState.ClientLanguage);
            Config = Configuration.Load();

            MusicManager = new MusicManager();
            MusicManager.DisableStreaming();

            var gameUtils = Service <ResidentResources> .Set();

            PlayerWatcher = PlayerWatchFactory.Create(Dalamud.Framework, Dalamud.ClientState, Dalamud.Objects);
            Service <MetaDefaults> .Set();

            var modManager = Service <ModManager> .Set();

            modManager.DiscoverMods();

            ObjectReloader = new ObjectReloader(modManager, Config.WaitFrames);

            ResourceLoader = new ResourceLoader(this);

            Dalamud.Commands.AddHandler(CommandName, new CommandInfo(OnCommand)
            {
                HelpMessage = "/penumbra - toggle ui\n/penumbra reload - reload mod file lists & discover any new mods",
            });

            ResourceLoader.Init();
            ResourceLoader.Enable();

            gameUtils.ReloadPlayerResources();

            SettingsInterface = new SettingsInterface(this);

            if (Config.EnableHttpApi)
            {
                CreateWebServer();
            }

            if (!Config.EnablePlayerWatch || !Config.IsEnabled)
            {
                PlayerWatcher.Disable();
            }

            PlayerWatcher.PlayerChanged += p =>
            {
                PluginLog.Debug("Triggered Redraw of {Player}.", p.Name);
                ObjectReloader.RedrawObject(p, RedrawType.OnlyWithSettings);
            };

            Api = new PenumbraApi(this);
            SubscribeItemLinks();
            Ipc = new PenumbraIpc(pluginInterface, Api);
        }
Exemplo n.º 4
0
        public void Dispose()
        {
            Ipc.Dispose();
            Api.Dispose();
            SettingsInterface.Dispose();
            ObjectReloader.Dispose();
            PlayerWatcher.Dispose();

            Dalamud.Commands.RemoveHandler(CommandName);

            ResourceLoader.Dispose();

            ShutdownWebServer();
        }
Exemplo n.º 5
0
        public bool Disable()
        {
            if (!Config.IsEnabled)
            {
                return(false);
            }

            Config.IsEnabled = false;
            Service <ResidentResources> .Get().ReloadPlayerResources();

            if (Config.EnablePlayerWatch)
            {
                PlayerWatcher.SetStatus(false);
            }

            Config.Save();
            ObjectReloader.RedrawAll(RedrawType.WithoutSettings);
            return(true);
        }
Exemplo n.º 6
0
    // Start is called before the first frame update
    //   This makes our prefabs and hooks up our companion script for each door.
    void Start()
    {
        // Make watchers for the triggers
        innerWatcher = innerTrigger.AddComponent <PlayerWatcher>();
        outerWatcher = outerTrigger.AddComponent <PlayerWatcher>();


        // Attach prefab doors to the inside and outside positions
        for (int outer = 0; outer <= 1; outer++)
        {
            GameObject door = Instantiate(doorPrefab, gameObject.transform, false);
            door.SetActive(true);
            Vector3 position = startPositions[outer];
            Modular_6m_Airlock_Door doorScript = door.AddComponent <Modular_6m_Airlock_Door>();
            doorScript.openPos  += position;
            doorScript.closePos += position;

            scripts[outer] = doorScript;
            doors[outer]   = door;
        }
    }
        public void ProcessPlayerWatchList()
        {
            PlayerList.Clear();
            MyAPIGateway.Players.GetPlayers(PlayerList);

            foreach (var player in PlayerList)
            {
                if (player.IsBot == true || player.Character == null)
                {
                    continue;
                }

                if (playerWatchList.ContainsKey(player) == true)
                {
                    //Regular Timers

                    if (Settings.General.EnableSpaceCargoShips == true)
                    {
                        playerWatchList[player].SpaceCargoShipTimer -= Settings.General.PlayerWatcherTimerTrigger;
                    }

                    if (Settings.General.EnablePlanetaryCargoShips == true)
                    {
                        playerWatchList[player].AtmoCargoShipTimer -= Settings.General.PlayerWatcherTimerTrigger;
                    }

                    if (Settings.General.EnableRandomEncounters == true)
                    {
                        //CoolDown Timers
                        if (playerWatchList[player].RandomEncounterCoolDownTimer > 0)
                        {
                            playerWatchList[player].RandomEncounterCoolDownTimer -= Settings.General.PlayerWatcherTimerTrigger;
                        }
                        else
                        {
                            playerWatchList[player].RandomEncounterCheckTimer -= Settings.General.PlayerWatcherTimerTrigger;
                        }

                        if (playerWatchList[player].RandomEncounterDistanceCoordCheck == Vector3D.Zero)
                        {
                            playerWatchList[player].RandomEncounterDistanceCoordCheck = player.GetPosition();
                        }
                    }

                    if (Settings.General.EnablePlanetaryInstallations == true)
                    {
                        if (playerWatchList[player].PlanetaryInstallationCooldownTimer > 0)
                        {
                            playerWatchList[player].PlanetaryInstallationCooldownTimer -= Settings.General.PlayerWatcherTimerTrigger;
                        }
                        else
                        {
                            playerWatchList[player].PlanetaryInstallationCheckTimer -= Settings.General.PlayerWatcherTimerTrigger;
                        }
                    }

                    if (Settings.General.EnableBossEncounters == true)
                    {
                        if (BossEncounterSpawner.IsPlayerInBossEncounter(player.IdentityId) == false)
                        {
                            if (playerWatchList[player].BossEncounterCooldownTimer > 0)
                            {
                                playerWatchList[player].BossEncounterCooldownTimer -= Settings.General.PlayerWatcherTimerTrigger;
                            }
                            else
                            {
                                playerWatchList[player].BossEncounterCheckTimer -= Settings.General.PlayerWatcherTimerTrigger;
                            }
                        }
                    }

                    //Apply Increment to Timers and Engage Spawners When Appropriate
                    if (playerWatchList[player].SpaceCargoShipTimer <= 0 && NPCWatcher.PendingNPCs.Count == 0)
                    {
                        playerWatchList[player].SpaceCargoShipTimer = rnd.Next(Settings.SpaceCargoShips.MinSpawnTime, Settings.SpaceCargoShips.MaxSpawnTime);
                        Logger.SkipNextMessage = true;
                        Logger.AddMsg("Attempting Space/Lunar Cargo Ship Spawn Near Player: " + player.DisplayName);
                        Logger.SkipNextMessage = true;
                        var spawnResult = SpaceCargoShipSpawner.AttemptSpawn(player.GetPosition());
                        Logger.AddMsg(spawnResult);
                    }

                    if (playerWatchList[player].AtmoCargoShipTimer <= 0 && NPCWatcher.PendingNPCs.Count == 0)
                    {
                        playerWatchList[player].AtmoCargoShipTimer = rnd.Next(Settings.PlanetaryCargoShips.MinSpawnTime, Settings.PlanetaryCargoShips.MaxSpawnTime);
                        Logger.SkipNextMessage = true;
                        Logger.AddMsg("Attempting Planetary Cargo Ship Spawn Near Player: " + player.DisplayName);
                        Logger.SkipNextMessage = true;
                        var spawnResult = PlanetaryCargoShipSpawner.AttemptSpawn(player.GetPosition());
                        Logger.AddMsg(spawnResult);
                    }

                    if (playerWatchList[player].RandomEncounterCheckTimer <= 0 && playerWatchList[player].RandomEncounterCoolDownTimer <= 0 && NPCWatcher.PendingNPCs.Count == 0)
                    {
                        playerWatchList[player].RandomEncounterCheckTimer = Settings.RandomEncounters.SpawnTimerTrigger;

                        if (Vector3D.Distance(player.GetPosition(), playerWatchList[player].RandomEncounterDistanceCoordCheck) >= Settings.RandomEncounters.PlayerTravelDistance)
                        {
                            playerWatchList[player].RandomEncounterDistanceCoordCheck = player.GetPosition();
                            Logger.SkipNextMessage = true;
                            Logger.AddMsg("Attempting Random Encounter Spawn Near Player: " + player.DisplayName);
                            Logger.SkipNextMessage = true;
                            var spawnResult = RandomEncounterSpawner.AttemptSpawn(player.GetPosition());
                            Logger.AddMsg(spawnResult);

                            if (spawnResult.StartsWith("Spawning Group - ") == true)
                            {
                                playerWatchList[player].RandomEncounterCoolDownTimer = Settings.RandomEncounters.PlayerSpawnCooldown;
                            }
                        }
                    }

                    if (playerWatchList[player].PlanetaryInstallationCheckTimer <= 0 && playerWatchList[player].PlanetaryInstallationCooldownTimer <= 0 && NPCWatcher.PendingNPCs.Count == 0)
                    {
                        playerWatchList[player].PlanetaryInstallationCheckTimer = Settings.PlanetaryInstallations.SpawnTimerTrigger;
                        Logger.SkipNextMessage = true;
                        Logger.AddMsg("Attempting Planetary Installation Spawn Near Player: " + player.DisplayName);
                        Logger.SkipNextMessage = true;
                        var spawnResult = PlanetaryInstallationSpawner.AttemptSpawn(player.GetPosition(), player);
                        Logger.AddMsg(spawnResult);

                        if (spawnResult.StartsWith("Spawning Group - ") == true)
                        {
                            playerWatchList[player].PlanetaryInstallationCooldownTimer = Settings.PlanetaryInstallations.PlayerSpawnCooldown;
                        }
                    }

                    if (playerWatchList[player].BossEncounterCheckTimer <= 0 && NPCWatcher.PendingNPCs.Count == 0)
                    {
                        playerWatchList[player].BossEncounterCheckTimer = Settings.BossEncounters.SpawnTimerTrigger;
                        Logger.SkipNextMessage = true;
                        Logger.AddMsg("Attempting Boss Encounter Spawn Near Player: " + player.DisplayName);
                        Logger.SkipNextMessage = true;
                        var spawnResult = BossEncounterSpawner.AttemptSpawn(player.GetPosition());
                        Logger.AddMsg(spawnResult);

                        if (spawnResult.StartsWith("Boss Encounter GPS Created") == true)
                        {
                            playerWatchList[player].BossEncounterCooldownTimer = Settings.BossEncounters.PlayerSpawnCooldown;
                        }
                    }
                }
                else
                {
                    var newPlayerWatcher = new PlayerWatcher();
                    playerWatchList.Add(player, newPlayerWatcher);
                }
            }
        }