Example #1
0
        public override void AI()
        {
            Lighting.AddLight(npc.position, 0.25F, 0.25F, 0.25F);

            //Get the inventory and corresponding player death position to be restored
            //The player death position is passed through the ai0 and ai1 parameters on the NewNPC method.
            // ai0 = deathPosition.X
            // ai1 = deathPosition.Y
            if (!attemptedToStoreInventory)
            {
                position     = new Point((int)npc.ai[0], (int)npc.ai[1]);
                npc.position = new Vector2(npc.ai[0], npc.ai[1]);
                mod.Logger.Debug($"ghost position - {position}");

                if (ModContent.GetInstance <MediumcoreGhostInventoriesWorld>().playerDeathInventoryMap.ContainsKey(position))
                {
                    storedInventory = ModContent.GetInstance <MediumcoreGhostInventoriesWorld>().playerDeathInventoryMap[position];
                }

                attemptedToStoreInventory = true;
            }
            //If inventory was attempted to be loaded and the inventory dict no longer contains the corresponding inventory, then kill this npc
            else if (!ModContent.GetInstance <MediumcoreGhostInventoriesWorld>().playerDeathInventoryMap.ContainsKey(position))
            {
                mod.Logger.Debug($"Killing ghost: no inventory - {position}");
                npc.active = false;
            }
        }
Example #2
0
        private void GivePlayerInventoryBack(Player player)
        {
            //Update stored inventory just incase it has changed (for example which items were favourited was received late)
            storedInventory = ModContent.GetInstance <MediumcoreGhostInventoriesWorld>().playerDeathInventoryMap[position];

            player.inventory  = storedInventory.deathInventory;
            player.armor      = storedInventory.deathArmor;
            player.dye        = storedInventory.deathDye;
            player.miscEquips = storedInventory.deathMiscEquips;
            player.miscDyes   = storedInventory.deathMiscDyes;
        }