protected void ClothingChanged(Farmer farmer, int newIndex) { bool initialUpdate = !currentIndex.HasValue; currentIndex = newIndex; T ev = (T)(object)currentIndex; Logger.Debug($"{farmer.Name}'s {clothingName} changed to {newIndex} {Enum.GetName(typeof(T), ev)}."); // remove old effect if (currentEffect != null) { currentEffect.Remove(currentItem, EffectChangeReason.ItemRemoved); currentEffect = null; } currentItem = GetCurrentItem(farmer); if (ItemDefinitions.GetEffectByIndex <T>(currentIndex ?? -1, out currentEffect)) { if (!isSuspended) { currentEffect.Apply(currentItem, initialUpdate ? EffectChangeReason.DayStart : EffectChangeReason.ItemPutOn); } } else { currentEffect = null; Logger.Debug($"Equipped {clothingName} has no effects"); } }
public void AddEffect(IEffect <LivingBeing> eff) { if (eff.CanApply(this)) { this._currentEffect.Add(eff); eff.Apply(this); } }
public void Apply(GameObject target) { IEffect effect = CreateEffect(target); if (effect.CanApply()) { effect.Apply(); } }
/// <summary> /// Re-apply the current effects (after having them suspended) /// </summary> /// <param name="farmer"></param> public void Restore(Farmer farmer, EffectChangeReason reason) { if (isSuspended) { Logger.Debug($"Restore {clothingName} effects"); isSuspended = false; currentEffect?.Apply(currentItem, reason); } }
private void Clear() { if (resolveStack.Count == 0) { return; } IEffect next = resolveStack.Pop(); next.Apply(); }
protected override void Activate(Cell cell) { IEffect effect = abilityEffectData.CreateEffect(cell.FrontEntity.GameObject); if (effect.CanApply()) { effect.Apply(); } FinishMove(cell); }
void Update() { if (active == false) { return; } targets = myTarget.UpdateTarget(range); //Rotaciona torre para olhar na direção do inimigo if (targets.Count != 0) { partToRotate.rotation = myRotate.LookAt(targets[0].transform, transform); } myEffect.Apply(firepoint, attackSpeed, targets, damage); }
public void ApplyEffect <T>(IEffect <T> effect) { if (!_targets.TryGetValue(typeof(T), out List <object> effectTargets)) { return; } foreach (T effectTarget in effectTargets) { effect.Apply(effectTarget); if (effect.Kind != EffectKind.OneShot) { _activeEffects.Add(new ActiveEffect <T>(effect, effectTarget, effect.Timing, effect.Kind == EffectKind.Repeating)); } } }
/// <summary> /// Returns a new <see cref="Image"/> with the specified effect. /// </summary> /// <param name="image">Image object to which the effect is applied.</param> /// <param name="effect">Effect type.</param> /// <returns> /// Returns a new <see cref="Image"/>, result of applying the effect to specified image . /// </returns> public static Image ApplyEffect(this Image image, IEffect effect) { SentinelHelper.ArgumentNull(image, nameof(image)); Image imageWithEffect; using (var bmp = new Bitmap(image.Width, image.Height)) using (var graphics = Graphics.FromImage(bmp)) { bmp.SetResolution(image.HorizontalResolution, image.VerticalResolution); graphics.DrawImage( image, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, effect.Apply()); imageWithEffect = (Image)bmp.Clone(); } return(imageWithEffect); }
public void AddTurnEffect(IEffect effect) { effect.Apply(this); turnEffects.Add(effect); }
public void AddConstantEffect(IEffect effect) { effect.Apply(this); constantEffects.Add(effect); }
public void ApplyEffect(IEffect e) { Logger.Log("Applying effect " + e.Name); if (_currentImage != null) { Logger.Log("Push image to undo stack"); _undoStack.Push(_currentImage.Clone()); Logger.Log("Getting result"); Bitmap result = e.Apply((Bitmap)GetImageForEffect().Clone()); Logger.Log("Substitute result"); if (_selection == null) _currentImage = result; else { _selection = result; Substitute(); } Logger.Log("Setting \"WasChanged\""); this.WasChanged = true; } }
public float Decompose(DomainSelector domain, ITask parent, IHTNContext context, ref List <PrimitiveTaskSelector> plan, ref int score, int scoreThreshold, out int localCost) { localCost = 0; if (this._id == Guid.Empty) { return(0f); } if (parent != null && !this.Parents.Contains(parent)) { this.Parents.Clear(); this.Parents.Add(parent); } plan.Add(this); Stack <IEffect> effects = Pool.Get <Stack <IEffect> >(); Stack <IEffect> effects1 = Pool.Get <Stack <IEffect> >(); for (int i = 0; i < this._effects.Count; i++) { IEffect item = this._effects[i]; item.Apply(context, true, false); effects.Push(item); } for (int j = 0; j < this._expectedEffects.Count; j++) { IEffect effect = this._expectedEffects[j]; effect.Apply(context, true, true); effects1.Push(effect); } if (effects.Count <= 0) { Pool.Free <Stack <IEffect> >(ref effects); } else if (!context.AppliedEffects.ContainsKey(base.id)) { context.AppliedEffects.Add(base.id, effects); } else { Stack <IEffect> item1 = context.AppliedEffects[base.id]; if (item1 != null) { Pool.Free <Stack <IEffect> >(ref item1); } context.AppliedEffects[base.id] = effects; } if (effects1.Count <= 0) { Pool.Free <Stack <IEffect> >(ref effects1); } else if (!context.AppliedExpectedEffects.ContainsKey(base.id)) { context.AppliedExpectedEffects.Add(base.id, effects1); } else { Stack <IEffect> item2 = context.AppliedExpectedEffects[base.id]; if (item2 != null) { Pool.Free <Stack <IEffect> >(ref item2); } context.AppliedExpectedEffects[base.id] = effects1; } return(1f); }
public void ApplyEffect(Unit caster, Unit target, IEffect effect, int spellId) { SpellData spellData = SpellLibrary.GetSpell(spellId); Spell spell = caster.Character.Spells.GetSpell(spellId); if (effect.AoeMode == AoeMode.None) { switch (spellData.spellTargetMode) { case SpellTargetMode.SingleTarget: if (!target.isDead) { effect.Apply(caster, target, spell, this); if (target.character.health.currentValue == 0) { if (target.IsHumanPlayer == false) { OnUnitDead(arenaUnits.IndexOf(target)); } else { OnPlayerDead(); } } } break; case SpellTargetMode.Self: effect.Apply(caster, caster, spell, this); if (caster.character.health.currentValue == 0) { if (target.IsHumanPlayer == false) { OnUnitDead(arenaUnits.IndexOf(target)); } else { OnPlayerDead(); } } break; case SpellTargetMode.NoTarget: effect.Apply(caster, null, spell, this); if (caster.character.health.currentValue == 0) { if (target.IsHumanPlayer == false) { OnUnitDead(arenaUnits.IndexOf(target)); } else { OnPlayerDead(); } } break; } } else { ApplyAoeEffect(caster, target, effect as AoeEffect, spell); } }