コード例 #1
0
 public static void OnNPCLoaded(NPC.NPCBase npc, JSONNode node)
 {
     if (node.TryGetAs <JSONNode>(GameLoader.SETTLER_INV, out var invNode))
     {
         npc.GetTempValues(true).Set(GameLoader.SETTLER_INV, new SettlerInventory(invNode));
     }
 }
コード例 #2
0
ファイル: Knight.cs プロジェクト: soolafsen/Pandaros.Settlers
 public static void OnNPCHit(NPC.NPCBase npc, Pipliz.Box <float> box)
 {
     if (npc != null && npc.Job != null && npc.Job.GetType() == typeof(Jobs.Knight))
     {
         box.Set(box.item1 - (box.item1 * .65f));
     }
 }
コード例 #3
0
        public static bool GetBestWeapon(NPC.NPCBase npc, int limit)
        {
            var hasItem = false;

            try
            {
                if (npc != null)
                {
                    var inv   = ColonistInventory.Get(npc);
                    var stock = npc.Colony.Stockpile;

                    hasItem = !inv.Weapon.IsEmpty();
                    IWeapon bestWeapon = null;

                    if (hasItem)
                    {
                        bestWeapon = WeaponFactory.WeaponLookup[inv.Weapon.Id];
                    }

                    foreach (var wep in WeaponFactory.WeaponLookup.Values.Where(w => w as IPlayerMagicItem == null && w is WeaponMetadata weaponMetadata && weaponMetadata.ItemType != null).Cast <WeaponMetadata>())
                    {
                        if (stock.Contains(wep.ItemType.ItemIndex) && bestWeapon == null ||
                            stock.Contains(wep.ItemType.ItemIndex) && bestWeapon != null &&
                            bestWeapon.Damage.TotalDamage() < wep.Damage.TotalDamage() &&
                            stock.AmountContained(ItemId.GetItemId(bestWeapon.name)) > limit)
                        {
                            bestWeapon = wep;
                        }
                    }

                    if (bestWeapon != null)
                    {
                        var wepId = ItemId.GetItemId(bestWeapon.name);
                        if (hasItem && inv.Weapon.Id != wepId || !hasItem)
                        {
                            hasItem = true;
                            stock.TryRemove(wepId);

                            if (!inv.Weapon.IsEmpty())
                            {
                                stock.Add(inv.Weapon.Id);
                            }

                            inv.Weapon = new ItemState
                            {
                                Id         = wepId,
                                Durability = bestWeapon.WepDurability
                            };
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                APILogger.LogError(ex);
            }

            return(hasItem);
        }
コード例 #4
0
ファイル: Knight.cs プロジェクト: soolafsen/Pandaros.Settlers
 public void OnAssignedNPC(NPCBase npc)
 {
     _usedNPC     = npc;
     _tmpVals     = npc.GetTempValues(true);
     _colony      = npc.Colony;
     _inv         = SettlerInventory.GetSettlerInventory(npc);
     _playerState = PlayerState.GetPlayerState(_colony.Owner);
     _stock       = Stockpile.GetStockPile(_colony.Owner);
 }
コード例 #5
0
ファイル: Knight.cs プロジェクト: soolafsen/Pandaros.Settlers
        public virtual void OnRemove()
        {
            _isValid = false;

            if (_usedNPC != null)
            {
                _usedNPC.ClearJob();
                _usedNPC = null;
            }
        }
コード例 #6
0
        public static void Heal(this NPC.NPCBase nPC, float heal)
        {
            nPC.health += heal;

            if (nPC.health > NPC.NPCBase.MaxHealth)
            {
                nPC.health = NPC.NPCBase.MaxHealth;
            }

            nPC.Update();
        }
コード例 #7
0
        public static GuardBaseJob.GuardSettings GetWeapon(NPC.NPCBase npc)
        {
            GuardBaseJob.GuardSettings weapon = null;
            var inv = SettlerInventory.GetSettlerInventory(npc);

            foreach (var w in Items.ItemFactory.WeaponGuardSettings)
            {
                if (npc.Inventory.Contains(w.recruitmentItem) || inv.Weapon.Id == w.recruitmentItem.Type)
                {
                    weapon = w;
                    break;
                }
            }

            return(weapon);
        }
コード例 #8
0
 public static void OnNPCSaved(NPC.NPCBase npc, JSONNode node)
 {
     node.SetAs(GameLoader.SETTLER_INV, SettlerInventory.GetSettlerInventory(npc).ToJsonNode());
 }
コード例 #9
0
 public static void OnNPCDied(NPC.NPCBase npc)
 {
     SettlerInventory.GetSettlerInventory(npc);
     UpdateFoodUse(npc.Colony.Owner);
 }
コード例 #10
0
ファイル: Knight.cs プロジェクト: soolafsen/Pandaros.Settlers
 public void OnRemovedNPC()
 {
     _usedNPC = null;
     JobTracker.Add(this);
 }