public EffectController() : base(0x1B72)
 {
     Movable       = false;
     Visible       = false;
     m_TriggerType = EffectTriggerType.Sequenced;
     m_EffectLayer = (EffectLayer)255;
 }
Exemplo n.º 2
0
    void DrawDataEffects(EffectRegister effectsByRole, EffectTriggerType trigger)
    {
        var effcond = effectsByRole.First(eff => eff.Key.tType == trigger).Key;

        for (var i = 0; i < effectsByRole[effcond].Effects.Count; i++)
        {
            Bh();
            var cached = effectsByRole[effcond].Effects[i];
            effectsByRole[effcond].Effects[i] =
                (BaseEffectData)EditorGUILayout.ObjectField(effectsByRole[effcond].Effects[i], typeof(BaseEffectData),
                                                            true);

            if (cached != effectsByRole[effcond].Effects[i])
            {
                SaveChanges();
            }

            if (GUILayout.Button("-", WidthXS))
            {
                var effect = effectsByRole[effcond].Effects[i];
                effectsByRole[effcond].Effects.Remove(effect);
                SaveChanges();
            }

            Eh();
        }
    }
Exemplo n.º 3
0
 public EffectController()
     : base(0x1B72)
 {
     Movable = false;
     Visible = false;
     m_TriggerType = EffectTriggerType.Sequenced;
     m_EffectLayer = (EffectLayer)255;
 }
Exemplo n.º 4
0
 public static void UpdateAurasToActor(
     List <AbstractActor> actors,
     AbstractActor movingActor,
     Vector3 movingActorPosition,
     EffectTriggerType triggerSource,
     bool forceUpdate)
 {
     // ignore position updates
 }
Exemplo n.º 5
0
        public EffectController() : base(0x1B72)
        {
            Movable              = false;
            Visible              = false;
            m_TriggerType        = EffectTriggerType.Sequenced;
            m_MissileEffectLayer = (EffectLayer)255;

            m_LastEffect = DateTime.Now;

            m_Message = "";
        }
Exemplo n.º 6
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            if (version == 0)
            {
                m_TriggerPlayersOnly = reader.ReadBool();
            }

            m_Cooldown   = reader.ReadTimeSpan();
            m_LastEffect = reader.ReadDateTime();

            ActivateMode = reader.ReadInt();
            ActivateItem = reader.ReadItem();

            m_TriggerDelay = reader.ReadTimeSpan();
            m_SoundDelay   = reader.ReadTimeSpan();
            m_MissileDelay = reader.ReadTimeSpan();

            m_Source  = ReadEntity(reader);
            m_Target  = ReadEntity(reader);
            m_Trigger = reader.ReadItem() as EffectController;

            m_MissileFixedDirection = reader.ReadBool();
            m_MissileExplodes       = reader.ReadBool();
            m_SoundAtTrigger        = reader.ReadBool();

            m_MessageDelay     = reader.ReadTimeSpan();
            m_MessageAtTrigger = reader.ReadBool();
            m_Message          = reader.ReadString();

            m_MissileEffectType  = (ECEffectType)reader.ReadEncodedInt();
            m_MissileEffectLayer = (EffectLayer)reader.ReadEncodedInt();
            m_TriggerType        = (EffectTriggerType)reader.ReadEncodedInt();

            m_MissileItemID                = reader.ReadEncodedInt();
            m_MissileHue                   = reader.ReadEncodedInt();
            m_MissileRenderMode            = reader.ReadEncodedInt();
            m_MissileSpeed                 = reader.ReadEncodedInt();
            m_MissileDuration              = reader.ReadEncodedInt();
            m_MissileParticleEffect        = reader.ReadEncodedInt();
            m_MissileExplodeParticleEffect = reader.ReadEncodedInt();
            m_MissileExplodesound          = reader.ReadEncodedInt();
            m_MissileUnknown               = reader.ReadEncodedInt();
            m_SoundID      = reader.ReadEncodedInt();
            m_TriggerRange = reader.ReadEncodedInt();
        }
Exemplo n.º 7
0
    void DrawLabelAndAddTrigger(EffectRegister effectsByRole, EffectTriggerType trigger)
    {
        var effcond = effectsByRole.First(eff => eff.Key.tType == trigger).Key;

        Bh();

        GUILayout.Label(trigger.ToString());
        if (GUILayout.Button("+", WidthXS))
        {
            effectsByRole[effcond].Effects.Add(null);
            SaveChanges();
        }

        Eh();
    }
Exemplo n.º 8
0
/*
 *              private IEntity ReadEntity( GenericReader reader )
 *              {
 *                      return World.FindEntity( reader.ReadInt() );
 *              }
 */
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
            {
                m_FlashType = (FlashType)reader.ReadEncodedInt();
                goto case 0;
            }

            case 0:
            {
                m_EffectDelay  = reader.ReadTimeSpan();
                m_TriggerDelay = reader.ReadTimeSpan();
                m_SoundDelay   = reader.ReadTimeSpan();

                m_Source  = reader.ReadEntity();
                m_Target  = reader.ReadEntity();
                m_Trigger = reader.ReadItem() as EffectController;

                m_FixedDirection     = reader.ReadBool();
                m_Explodes           = reader.ReadBool();
                m_PlaySoundAtTrigger = reader.ReadBool();

                m_EffectType  = (ECEffectType)reader.ReadEncodedInt();
                m_EffectLayer = (EffectLayer)reader.ReadEncodedInt();
                m_TriggerType = (EffectTriggerType)reader.ReadEncodedInt();

                m_ItemID                = reader.ReadEncodedInt();
                m_Hue                   = reader.ReadEncodedInt();
                m_RenderMode            = reader.ReadEncodedInt();
                m_Speed                 = reader.ReadEncodedInt();
                m_Duration              = reader.ReadEncodedInt();
                m_ParticleEffect        = reader.ReadEncodedInt();
                m_ExplodeParticleEffect = reader.ReadEncodedInt();
                m_ExplodeSound          = reader.ReadEncodedInt();
                m_Unknown               = reader.ReadEncodedInt();
                m_SoundID               = reader.ReadEncodedInt();
                m_TriggerRange          = reader.ReadEncodedInt();

                break;
            }
            }
        }
Exemplo n.º 9
0
        public IEnumerator ResolveTargets(IUiCard uiCard, EffectTriggerType trigger)
        {
            if (uiCard == null)
            {
                yield return(0);
            }

            var card = uiCard.Data.RuntimeData;

            //grab all effects from the card
            var effects = GetEffects(card);

            //return if the specified trigger is not present
            if (!effects.Any(eff => eff.Key.tType == trigger))
            {
                yield return(0);
            }

            var effectsByTrigger = effects[effects.First(eff => eff.Key.tType == trigger).Key].Effects;

            //register them in the card with their respective targets
            foreach (var effect in effectsByTrigger)
            {
                var targetType = effect.Target;
                var targets    = targetType.GetTargets(card, GameData.RuntimeGame);

                if (targetType.IsDynamic)
                {
                    uiCard.Target();

                    targetType.Subscribe(this);

                    //keep checking the amount of targets until they are completely filled
                    yield return(new WaitWhile(() =>
                                               targetType.GetTargets(card, GameData.RuntimeGame).Length != targetType.TargetAmount));

                    targets = targetType.GetTargets(card, GameData.RuntimeGame);
                    effect.Target.Unsubscribe(this);
                }

                card.AddTargets(effect, targets);
            }

            //resolve the spell
            Controller.PlayerController.Player.Play(card);

            OnTargetsResolve.Invoke(uiCard);
        }
Exemplo n.º 10
0
        //TODO: Merge these two classes into one. I'm building out the relic class now, so don't want too f**k up two things at once
        public static void DispatchEffects(IRuntimeCard card, EffectTriggerType triggerType)
        {
            //grab all effects from the card
            var effects = GetEffects(card);

            //return if the specified trigger is not present
            if (effects.All(eff => eff.Key.tType != triggerType))
            {
                return;
            }

            //grab all effects of the specified trigger
            var effectsByTrigger = effects[effects.First(eff => eff.Key.tType == triggerType).Key].Effects;

            //dispatch all effects
            foreach (var effect in effectsByTrigger)
            {
                EffectsResolver.Resolve(effect, card, card.Targets[effect]);
            }
        }
Exemplo n.º 11
0
    void DrawTriggersOperations()
    {
        GUILayout.Label("Triggers Effects", EditorStyles.boldLabel);
        Bh();
        GUILayout.Label("Selected Trigger: ", WidthL);
        ChosenTrigger = (EffectTriggerType)EditorGUILayout.EnumPopup(ChosenTrigger, WidthS);
        Eh();

        Bh();
        GUILayout.Label("Operations:");
        if (GUILayout.Button("Add Trigger", WidthL))
        {
            AddTrigger();
        }
        if (GUILayout.Button("Remove Trigger", WidthL))
        {
            RemoveTrigger();
        }
        Eh();
    }
Exemplo n.º 12
0
 public static void Postfix(AuraCache __instance, AbstractActor fromActor, MechComponent auraComponent, EffectData effectData, float distSquared, EffectTriggerType triggerSource, ref bool __result)
 {
     /*AbstractActor Owner = (AbstractActor)FOwner.Invoke(__instance, new object[0] { });
      * //Log.LogWrite("AuraCache.AuraConditionsPassed prefix owner:" + Owner.DisplayName + ":"+Owner.GUID+" from: "+fromActor.DisplayName+":"+fromActor.GUID+" component:"+auraComponent.defId+" effect:"+effectData.Description.Id+" res:"+__result+"\n");
      * if (__result == false) { return; }
      * ActivatableComponent activatable = auraComponent.componentDef.GetComponent<ActivatableComponent>();
      * if (activatable == null) { return; }
      * if (activatable.baseEffects.Contains(effectData)) {
      * //Log.LogWrite(" base effect\n");
      * return;
      * };
      * bool componentActive = ActivatableComponent.isComponentActivated(auraComponent);
      * if (activatable.onlineEffects.Contains(effectData) && (componentActive == false)) {
      * //Log.LogWrite(" online effect but not actiavted\n");
      * __result = false;
      * } else
      * if (activatable.offlineEffects.Contains(effectData) && (componentActive == true)) {
      * //Log.LogWrite(" offline effect but actiavted\n");
      * __result = false;
      * };*/
 }
Exemplo n.º 13
0
 /*public static void AddEffectIfNotPresent(this AuraCache instance, AbstractActor fromActor, AbstractActor movingActor, Vector3 movingActorPos, string effectCreatorId, EffectData effect, ref List<string> existingEffectIDs, EffectTriggerType triggerSource) {
  * object[] args = new object[7] { fromActor, movingActor, movingActorPos, effectCreatorId, effect, existingEffectIDs, triggerSource};
  * mAddEffectIfNotPresent.Invoke(instance, args);
  * existingEffectIDs = (List<string>)args[5];
  * }
  * public static void RemoveEffectIfPresent(this AuraCache instance, AbstractActor fromActor, string effectCreatorId, EffectData effect, List<Effect> existingEffects, EffectTriggerType triggerSource) {
  * object[] args = new object[5] { fromActor, effectCreatorId, effect, existingEffects, triggerSource };
  * mRemoveEffectIfPresent.Invoke(instance, args);
  * }*/
 public static bool Prefix(AuraCache __instance, AbstractActor fromActor, AbstractActor movingActor, Vector3 movingActorPos, MechComponent auraComponent, float distSquared, EffectTriggerType triggerSource, bool skipECMCheck)
 {
     /*AbstractActor Owner = (AbstractActor)FOwner.Invoke(__instance, new object[0] { });
      * List<Effect> all = Owner.Combat.EffectManager.GetAllEffectsCreatedBy(fromActor.GUID).FindAll((Predicate<Effect>)(x => x.targetID == Owner.GUID));
      * for (int index = 0; index < auraComponent.componentDef.statusEffects.Length; ++index) {
      * if (__instance.ShouldAffectThisActor(fromActor, auraComponent.componentDef.statusEffects[index], triggerSource)) {
      *  if (!skipECMCheck && (auraComponent.componentDef.statusEffects[index].targetingData.auraEffectType == AuraEffectType.ECM_GHOST || auraComponent.componentDef.statusEffects[index].targetingData.auraEffectType == AuraEffectType.ECM_GENERAL))
      *    Owner.Combat.FlagECMStateNeedsRefreshing();
      *  else if (__instance.AuraConditionsPassed(fromActor, auraComponent, auraComponent.componentDef.statusEffects[index], distSquared, triggerSource))
      *    __instance.AddEffectIfNotPresent(fromActor, movingActor, movingActorPos, auraComponent.componentDef.Description.Id, auraComponent.componentDef.statusEffects[index], ref auraComponent.createdEffectIDs, triggerSource);
      *  else
      *    __instance.RemoveEffectIfPresent(fromActor, auraComponent.componentDef.Description.Id, auraComponent.componentDef.statusEffects[index], all, triggerSource);
      * }
      * }*/
     return(false);
     //Log.LogWrite("AuraCache.UpdateAura prefix owner:" + Owner.DisplayName + ":" + Owner.GUID + " from: " + fromActor.DisplayName + ":" + fromActor.GUID + " component:" + auraComponent.defId + "\n");
 }
Exemplo n.º 14
0
 public static void Postfix(AuraCache __instance, AbstractActor fromActor, EffectData effect, EffectTriggerType triggerSource, ref bool __result)
 {
     //AbstractActor Owner = (AbstractActor)FOwner.Invoke(__instance, new object[0] { });
     //Log.LogWrite("AuraCache.ShouldAffectThisActor postfix owner:" + Owner.DisplayName + ":" + Owner.GUID + " from: " + fromActor.DisplayName + ":" + fromActor.GUID + " Effect:" + effect.Description.Id + " result:" + __result + "\n");
 }
Exemplo n.º 15
0
 public static bool Prefix(AuraCache __instance, AbstractActor fromActor, AbstractActor movingActor, Vector3 movingActorPos, float distSquared, EffectTriggerType triggerSource, bool forceUpdate)
 {
     //AbstractActor Owner = (AbstractActor)FOwner.Invoke(__instance, new object[0] { });
     //Log.LogWrite("AuraCache.UpdateAuras prefix owner:" + Owner.DisplayName + ":" + Owner.GUID + " from: " + fromActor.DisplayName + ":" + fromActor.GUID + " AuraComponents:" + fromActor.AuraComponents.Count + " forceUpdate:" + forceUpdate + "\n");
     return(false);
 }
Exemplo n.º 16
0
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            int version = reader.ReadInt();

            switch ( version )
            {
                case 0:
                {
                    m_EffectDelay = reader.ReadTimeSpan();
                    m_TriggerDelay = reader.ReadTimeSpan();
                    m_SoundDelay = reader.ReadTimeSpan();

                    m_Source = ReadEntity( reader );
                    m_Target = ReadEntity( reader );
                    m_Trigger = reader.ReadItem() as EffectController;

                    m_FixedDirection = reader.ReadBool();
                    m_Explodes = reader.ReadBool();
                    m_PlaySoundAtTrigger = reader.ReadBool();

                    m_EffectType = (EffectType)reader.ReadEncodedInt();
                    m_EffectLayer = (EffectLayer)reader.ReadEncodedInt();
                    m_TriggerType = (EffectTriggerType)reader.ReadEncodedInt();

                    m_ItemID = reader.ReadEncodedInt();
                    m_Hue = reader.ReadEncodedInt();
                    m_RenderMode = reader.ReadEncodedInt();
                    m_Speed = reader.ReadEncodedInt();
                    m_Duration = reader.ReadEncodedInt();
                    m_ParticleEffect = reader.ReadEncodedInt();
                    m_ExplodeParticleEffect = reader.ReadEncodedInt();
                    m_ExplodeSound = reader.ReadEncodedInt();
                    m_Unknown = reader.ReadEncodedInt();
                    m_SoundID = reader.ReadEncodedInt();
                    m_TriggerRange = reader.ReadEncodedInt();

                    break;
                }
            }
        }
Exemplo n.º 17
0
        public static bool Prefix(AuraCache __instance, AbstractActor fromActor, string effectCreatorId,
                                  EffectData effect, List <Effect> existingEffects, EffectTriggerType triggerSource)
        {
            Mod.Log.Trace("AC:REIP entered");

            bool allowMethod = true;

            Traverse      ownerT = Traverse.Create(__instance).Property("Owner");
            AbstractActor Owner  = ownerT.GetValue <AbstractActor>();

            // 1. When the same effectId is added, record every actor that contributes the same effect id. Only remove the effect if all actors have removed the effect
            string sourcesStat = $"{effect.Description.Id}_AH_SOURCES";
            string sourceValue = CombatantUtils.Label(fromActor);

            if (Owner.StatCollection.ContainsStatistic(sourcesStat))
            {
                Mod.Log.Debug($"  Removing effectSource: {sourceValue} from Owner: ({CombatantUtils.Label(Owner)}");
                string statSources = Owner.StatCollection.GetStatistic(sourcesStat).Value <string>();
                Mod.Log.Debug($"  -- statSources: ({statSources})");

                HashSet <string> newValues = new HashSet <string>();
                foreach (string value in statSources.Split(','))
                {
                    if (value != null && value != "")
                    {
                        newValues.Add(value);
                    }
                }
                if (newValues.Contains(sourceValue))
                {
                    newValues.Remove(sourceValue);
                }

                if (newValues.Count > 0)
                {
                    string newValue = string.Join(",", new List <string>(newValues).ToArray());
                    Mod.Log.Debug($"  changing effectSources on actor: ({CombatantUtils.Label(Owner)}) from: ({statSources}) to: ({newValue})");
                    Owner.StatCollection.Set(sourcesStat, newValue);
                    allowMethod = false;
                }
                else
                {
                    Mod.Log.Debug($"  No effectSources remaining on actor: ({CombatantUtils.Label(Owner)}), removing statistic: {sourcesStat}");
                    Owner.StatCollection.RemoveStatistic(sourcesStat);
                }
            }

            // 2. When multiple effects add to the same statistic, record each value as an array
            if (effect != null && effect.effectType == EffectType.StatisticEffect)
            {
                string valuesStat  = $"{effect.Description.Id}_AH_VALUES";
                string effectValue = $"{effect.Description.Id}:{CombatantUtils.Label(fromActor)}:{effectCreatorId}:{effect.statisticData.modValue}";
                if (Owner.StatCollection.ContainsStatistic(valuesStat))
                {
                    Mod.Log.Debug($"  Removing effectValue: {effectValue} from Owner: ({CombatantUtils.Label(Owner)}");
                    string statValues = Owner.StatCollection.GetStatistic(valuesStat).Value <string>();
                    Mod.Log.Debug($"  -- statValues: ({statValues})");

                    HashSet <string> newValues = new HashSet <string>();
                    foreach (string value in statValues.Split(','))
                    {
                        if (value != null || value != "")
                        {
                            newValues.Add(value);
                        }
                    }
                    if (newValues.Contains(effectValue))
                    {
                        newValues.Remove(effectValue);
                    }

                    if (newValues.Count > 0)
                    {
                        string newValue = string.Join(",", new List <string>(newValues).ToArray());
                        Mod.Log.Debug($"  changing statValues from: ({statValues}) to: ({newValue})");
                        Owner.StatCollection.Set(valuesStat, newValue);
                        allowMethod = false;
                    }
                    else
                    {
                        Mod.Log.Debug($"  No effects remaining on actor: ({CombatantUtils.Label(Owner)}), removing all values");
                        Owner.StatCollection.RemoveStatistic(valuesStat);
                    }
                }
            }

            return(allowMethod);
        }
Exemplo n.º 18
0
 public EffectTriggerCondition(EffectTriggerType tType, int triggerAmt, int currentAmt)
 {
     this.tType      = tType;
     this.triggerAmt = triggerAmt;
     this.currentAmt = currentAmt;
 }
Exemplo n.º 19
0
 public static void Postfix(AuraCache __instance, AbstractActor fromActor, AbstractActor movingActor, Vector3 movingActorPos,
                            MechComponent auraComponent, float distSquared, EffectTriggerType triggerSource, bool skipECMCheck)
 {
     Mod.Log.Trace("AC:UA:MC entered");
 }
Exemplo n.º 20
0
        public static void Prefix(AuraCache __instance, ref bool __result, AbstractActor fromActor, AbstractActor movingActor, Vector3 movingActorPos,
                                  string effectCreatorId, EffectData effect, ref List <string> existingEffectIDs, EffectTriggerType triggerSource)
        {
            Mod.Log.Trace("AC:AEINP:pre entered");

            Traverse      ownerT = Traverse.Create(__instance).Property("Owner");
            AbstractActor Owner  = ownerT.GetValue <AbstractActor>();

            // 1. When the same effectId is added, record every actor that contributes the same effect id. Only remove the effect if all actors have removed the effect
            string sourcesStat = $"{effect.Description.Id}_AH_SOURCES";
            string sourceValue = CombatantUtils.Label(fromActor);

            Mod.Log.Debug($"  sourceValue: ({sourceValue})");
            if (!Owner.StatCollection.ContainsStatistic(sourcesStat))
            {
                Owner.StatCollection.AddStatistic <string>(sourcesStat, "");
                Owner.StatCollection.Set <string>(sourcesStat, sourceValue);
                //Mod.Log.Debug($"  new sources statistic: ({sourcesStat}) value: ({sourceValue})");
            }
            else
            {
                string statSources = Owner.StatCollection.GetStatistic(sourcesStat).Value <string>();

                HashSet <string> sources = new HashSet <string>();
                foreach (string value in statSources.Split(','))
                {
                    if (value != null && !value.Equals(sourceValue))
                    {
                        sources.Add(value);
                    }
                }
                sources.Add(sourceValue);

                string newValue = string.Join(",", new List <string>(sources).ToArray());
                Owner.StatCollection.Set <string>(sourcesStat, newValue);
                //Mod.Log.Debug($"  sources statistic: ({sourcesStat}) value: ({newValue})");
            }

            // 2. When multiple effects add to the same statistic, record each value as an array
            if (effect.effectType == EffectType.StatisticEffect)
            {
                Mod.Log.Debug($"Tracking statEffect vs statistic: {effect.statisticData.statName} fromActor: {CombatantUtils.Label(fromActor)} effectCreatorId: {effectCreatorId} " +
                              $"vs. movingActor: {CombatantUtils.Label(movingActor)}");

                // Create a tracking stat, denoting effectId:fromActorGUID:strength
                string valuesStat  = $"{effect.Description.Id}_AH_VALUES";
                string effectValue = $"{effect.Description.Id}:{CombatantUtils.Label(fromActor)}:{effectCreatorId}:{effect.statisticData.modValue}";
                Mod.Log.Debug($"  effectValue: ({effectValue})");
                if (!Owner.StatCollection.ContainsStatistic(valuesStat))
                {
                    Owner.StatCollection.AddStatistic <string>(valuesStat, "");
                    Owner.StatCollection.Set <string>(valuesStat, effectValue);
                    //Mod.Log.Debug($"  new values statistic: ({valuesStat}) value: ({effectValue})");
                }
                else
                {
                    string statValues = Owner.StatCollection.GetStatistic(valuesStat).Value <string>();

                    HashSet <string> values = new HashSet <string>();
                    foreach (string value in statValues.Split(','))
                    {
                        if (value != null && !value.Equals(effectValue))
                        {
                            values.Add(value);
                        }
                    }
                    values.Add(effectValue);

                    string newValue = string.Join(",", new List <string>(values).ToArray());
                    Owner.StatCollection.Set <string>(valuesStat, newValue);
                    //Mod.Log.Debug($"  values statistic: ({valuesStat}) value: ({newValue})");
                }
            }
        }