public static Option <IEquipment> Equip( this IEquipmentHolder holder, IEquipment item, Set <string> tags) { Ensure.That(holder, nameof(holder)).IsNotNull(); return(holder.Equipments.Equip(item, tags)); }
public static Option <EquipmentConfiguration> FindEquipConfiguration( this IEquipmentHolder holder, IEquipment item, Set <string> tags) { Ensure.That(holder, nameof(holder)).IsNotNull(); return(holder.Equipments.FindConfiguration(item, tags)); }
public static IEquipment Equip( this IEquipmentHolder holder, IEquipment item, EquipmentConfiguration configuration) { Ensure.That(holder, nameof(holder)).IsNotNull(); return(holder.Equipments.Equip(item, configuration)); }
public void ClearEquippedItem(IEquipmentHolder holder, bool isSwap) { if (holder.Item == null) { return; } var item = holder.Item; var owner = holder.Owner; var node = item.GetNode <EquipmentNode>(); ClearStats(holder); item.ClearParent(owner); holder.Item = null; if (node?.Equipment != null) { ClearStats(node.Equipment); } if (node?.Item != null && node.Item.Inventory == holder.Container) { node.Item.SetContainer(null); } item.Post(new EquipmentChanged(null, null)); if (!isSwap) { owner.Post(new EquipmentChanged(owner, holder)); holder.OnItemChanged?.Invoke(null); } }
public static Option <IEquipment> Unequip( this IEquipmentHolder holder, string slot, Option <Node> dropTo) { Ensure.That(holder, nameof(holder)).IsNotNull(); return(holder.Equipments.Unequip(slot, dropTo)); }
public static Equipment GetEquipment([NotNull] this IEquipmentHolder holder, [NotNull] string slot) { Ensure.Any.IsNotNull(holder, nameof(holder)); Ensure.Any.IsNotNull(slot, nameof(slot)); return(holder.Equipments.TryGetValue(slot, out var value) ? value : null); }
protected virtual void PlayAnimation( IEquipmentHolder holder, Equipment equipment, Option <Node> dropTo, Godot.Animation animation, IAnimationManager animationManager, InteractionContext context) { animationManager.OnAnimationEvent .OfType <TriggerEvent>() .Where(e => e.Name == "Action" && e.Argument.Contains(Key)) .Take(1) .TakeUntil(Disposed.Where(identity)) .Subscribe(_ => Unequip(holder, equipment, dropTo, context), this); if (animationManager is IAnimationStateManager stateManager && AnimatorPath.IsSome && StatesPath.IsSome) { ( from animator in AnimatorPath.Bind(stateManager.FindAnimator) from states in StatesPath.Bind(stateManager.FindStates) from state in ActionState select(animator, states, state)).Iter(t => { t.animator.Animation = animation; t.states.Playback.Travel(t.state); }); }
public static bool HasEquipment(this IEquipmentHolder holder, IEquipment equipment) { Ensure.That(holder, nameof(holder)).IsNotNull(); Ensure.That(equipment, nameof(equipment)).IsNotNull(); return(holder.Equipments.Items.Values.Contains(equipment)); }
public static IEquipment Unequip( this IEquipmentHolder holder, IEquipment item, Option <Node> dropTo) { Ensure.That(holder, nameof(holder)).IsNotNull(); return(holder.Equipments.Unequip(item, dropTo)); }
public void SetSlot(IEquipmentHolder slot) { if (_slot != null) { _slot.OnItemChanged -= UpdateItem; } _slot = slot; _slot.OnItemChanged += UpdateItem; UpdateItem(_slot.Item); }
public static Equipment Equip( [NotNull] this IEquipmentHolder holder, [NotNull] Equipment item, [NotNull] EquipmentConfiguration configuration) { Ensure.Any.IsNotNull(holder, nameof(holder)); return(holder.Equipments.Equip(item, configuration)); }
public static Equipment Equip( [NotNull] this IEquipmentHolder holder, [NotNull] Equipment item, params string[] tags) { Ensure.Any.IsNotNull(holder, nameof(holder)); return(holder.Equipments.Equip(item, tags)); }
public static Equipment Unequip( [NotNull] this IEquipmentHolder holder, [NotNull] string slot, [CanBeNull] Node dropTo) { Ensure.Any.IsNotNull(holder, nameof(holder)); return(holder.Equipments.Unequip(slot, dropTo)); }
public static EquipmentConfiguration FindEquipConfiguration( [NotNull] this IEquipmentHolder holder, [NotNull] Equipment item, params string[] tags) { Ensure.Any.IsNotNull(holder, nameof(holder)); return(holder.Equipments.FindConfiguration(item, tags)); }
public override void Equip(IEquipmentHolder holder) { Ensure.Any.IsNotNull(holder, nameof(holder)); Mesh.GetParent()?.RemoveChild(Mesh); holder.Skeleton.AddChild(Mesh); _mesh = Mesh.GetPath(); }
public EquipmentContainer( IEnumerable <EquipmentSlot> slots, IEquipmentHolder holder, ILoggerFactory loggerFactory) : base(loggerFactory) { Ensure.That(slots, nameof(slots)).IsNotNull(); Ensure.That(holder, nameof(holder)).IsNotNull(); Holder = holder; Slots = slots.ToMap(); }
public override void OnEquip(IEquipmentHolder holder, Equipment equipment) { base.OnEquip(holder, equipment); foreach (var mesh in equipment.Meshes) { equipment.Transform = new Transform(Basis.Identity, Vector3.Zero); mesh.Skeleton = holder.Skeleton.GetPath(); } }
private void ClearStats(IEquipmentHolder holder) { if (holder.CurrentStats == null) { return; } for (int i = 0; i < holder.CurrentStats.Count; i++) { holder.CurrentStats[i].Remove(); } holder.CurrentStats.Clear(); }
public override void OnEquip(IEquipmentHolder holder, Equipment equipment) { base.OnEquip(holder, equipment); var transform = equipment.Markers.Find(Key).Map(m => m.Transform.Inverse()) .IfNone(() => new Transform(Basis.Identity, Vector3.Zero)); foreach (var mesh in equipment.Meshes) { equipment.SetTransform(transform); mesh.Skeleton = mesh.GetPathTo(equipment.Node); } }
public virtual Node GetParent([NotNull] IEquipmentHolder holder) { switch (EquipType) { case EquipType.Attachment: return(holder.Markers[Key]); case EquipType.Rigged: return(holder.Skeleton); default: throw new ArgumentOutOfRangeException(); } }
public override void OnEquip(IEquipmentHolder holder, Equipment equipment) { base.OnEquip(holder, equipment); var transform = equipment.Markers.TryGetValue(Key, out var attachPoint) ? attachPoint.Transform.Inverse() : new Transform(Basis.Identity, Vector3.Zero); foreach (var mesh in equipment.Meshes) { equipment.Transform = transform; mesh.Skeleton = equipment.GetPath(); } }
protected override void DoExecute( IEquipmentHolder holder, Equipment equipment, InteractionContext context) { Ensure.That(holder, nameof(holder)).IsNotNull(); var configuration = equipment.Configuration; var dropTo = holder.Spatial.GetCurrentScene().Map(s => s.ItemsRoot); var args = from manager in Optional(holder).OfType <IAnimatable>().Map(a => a.AnimationManager) from animation in configuration.UnequipAnimation.Concat(Animation).HeadOrNone() select(manager, animation); args.HeadOrNone().Match( v => PlayAnimation(holder, equipment, dropTo, v.animation, v.manager, context), () => Unequip(holder, equipment, dropTo, context) ); }
public virtual Node GetParent(IEquipmentHolder holder) { Ensure.That(holder, nameof(holder)).IsNotNull(); switch (EquipType) { case EquipType.Attachment: return(holder.Markers.Find(Key).Match(v => v, () => throw new ArgumentOutOfRangeException(nameof(holder), $"The specified equipment holder does not contain slot '{Key}'."))); case EquipType.Rigged: return(holder.Skeleton); default: throw new ArgumentOutOfRangeException(); } }
public bool ClearAndAddToInventory(IEquipmentHolder holder, bool isSwap) { var inventory = holder.Owner.Get <ItemInventory>(); if (inventory == null || inventory.IsFull) { holder.LastEquipStatus = "Owner inventory full"; return(false); } var oldItem = holder.Item; ClearEquippedItem(holder, isSwap); if (!inventory.TryAdd(oldItem)) { holder.LastEquipStatus = "Owner inventory rejected old item"; return(false); } return(true); }
public override void Equip(IEquipmentHolder holder) { Ensure.Any.IsNotNull(holder, nameof(holder)); if (holder.Markers.TryGetValue(Slot, out var marker)) { Mesh.GetParent()?.RemoveChild(Mesh); marker.AddChild(Mesh); _mesh = Mesh.GetPath(); } else { throw new ArgumentOutOfRangeException( nameof(holder), $"The equipment holder does not have a proper attach point: '{Slot}'."); } }
public void SetStats(IEquipmentHolder holder, EquipmentNode node) { if (node.Equipment == null) { return; } //var ownerStats = SlotOwner.GetEntity().Stats; //var skillComponent = Item.Get<SkillRequirement>(); //var skill = skillComponent != null ? skillComponent.Skill : GameData.Skills.GetID(0); //if (TargetSlot == EquipmentSlotType.MainHand) { // bool ranged = Item.Tags.Contain(EntityTags.RangedWeapon); // var charSkill = ownerStats.Get(skill); // if (charSkill != null) { // _currentStats.Add(new DerivedStatModHolder(charSkill, Item.Stats.Get(Stats.ToHit), RpgSettings.SkillStandardToHitBonus)); // } // _currentStats.Add(new DerivedStatModHolder(ownerStats.Get(ranged ? Stats.BonusPowerRanged : Stats.BonusPowerMelee), Item.Stats.Get(Stats.Power), 1)); // _currentStats.Add(new DerivedStatModHolder(ownerStats.Get(ranged ? Stats.BonusToHitRanged : Stats.BonusToHitMelee), Item.Stats.Get(Stats.ToHit), 1)); // _currentStats.Add(new DerivedStatModHolder(ownerStats.Get(ranged ? Stats.BonusCritRanged : Stats.BonusCritMelee), Item.Stats.Get(Stats.CriticalHit), 1)); //} ClearStats(node.Equipment); var itemStats = node.Equipment.GetEntity().Get <StatsContainer>(); if (node.Equipment.Mods == null || node.Equipment.Mods.Length != node.Equipment.StatsToEquip.Count) { node.Equipment.Mods = new StatModHolder[node.Equipment.StatsToEquip.Count]; for (int i = 0; i < node.Equipment.Mods.Length; i++) { node.Equipment.Mods[i] = new DerivedStatModHolder(itemStats.Get(node.Equipment.StatsToEquip[i]), 1); } } var slotStats = holder.Owner.Get <StatsContainer>(); for (int i = 0; i < node.Equipment.Mods.Length; i++) { node.Equipment.Mods[i].Attach(slotStats.Get(node.Equipment.Mods[i].StatID)); } }
public virtual void Unequip(IEquipmentHolder holder) { Configuration.OnUnequip(holder, this); UpdateEquipState(false); }
public EquipmentChanged(IEquipmentHolder slot, Entity item) { Item = item; Slot = slot; }
public virtual void Equip(IEquipmentHolder holder) { UpdateEquipState(true); Configuration.OnEquip(holder, this); }
public static bool HasEquipment([NotNull] this IEquipmentHolder holder, [NotNull] string slot) => GetEquipment(holder, slot) != null;