public bool LearnSkill(Skill skill) { if (SkillPoints <= 0) { return(false); } if (KnownSkills.Any(r => r.Skill == skill)) { return(false); } if (!SkillRequarements.Check(skill, this)) { return(false); } SkillPoints--; KnownSkills.Add(GetSkillReference(skill)); return(true); }
/// <summary> /// Resets the NPC's state back to the initial values, and re-creates the inventory and equipped items they /// will spawn with. /// </summary> void LoadSpawnState() { // All items remaining in the inventory or equipment should NOT be referenced! // Items that were dropped should have been removed when dropping Inventory.RemoveAll(true); Equipped.RemoveAll(true); // Grab the respawn items from the template var templateID = CharacterTemplateID; if (!templateID.HasValue) { return; } var template = CharacterTemplateManager[templateID.Value]; if (template == null) { return; } // Create the inventory items var spawnInventory = template.Inventory; if (spawnInventory != null) { foreach (var inventoryItem in spawnInventory) { var item = inventoryItem.CreateInstance(); if (item == null) { continue; } Inventory.Add(item); } } // Create the equipped items var spawnEquipment = template.Equipment; if (spawnEquipment != null) { foreach (var equippedItem in spawnEquipment) { var item = equippedItem.CreateInstance(); if (item == null) { continue; } if (!Equipped.Equip(item)) { item.Destroy(); } } } // Reset the known skills var spawnKnownSkills = template.KnownSkills; KnownSkills.SetValues(spawnKnownSkills); }