Boolean RunState(State state, Boolean hitpause) { if (state == null) throw new ArgumentNullException("state"); foreach (StateController controller in state.Controllers) { if (hitpause == true && controller.IgnoreHitPause == false) continue; Boolean persistencecheck = state.Number < 0 || PersistenceCheck(controller, controller.Persistence); if (persistencecheck == false) continue; Boolean triggercheck = controller.Triggers.Trigger(m_character); if (triggercheck == false) continue; if (controller.Persistence == 0 || controller.Persistence > 1) m_persistencemap[controller] = controller.Persistence; controller.Run(m_character); if (controller is Controllers.ChangeState || controller is Controllers.SelfState) return true; } return false; }
State CreateState(TextSection textsection, List<StateController> controllers) { if (textsection == null) throw new ArgumentNullException("textsection"); if (controllers == null) throw new ArgumentNullException("controllers"); Match match = m_statertitleregex.Match(textsection.Title); if (match.Success == false) return null; Int32 statenumber = Int32.Parse(match.Groups[1].Value); foreach (StateController controller in controllers) { if (controller.IsValid() == true) continue; Log.Write(LogLevel.Warning, LogSystem.StateSystem, "Error parsing state #{0}, controller {1} - '{2}'", statenumber, controller.GetType().Name, controller.Label); } controllers.RemoveAll(x => x.IsValid() == false); if (m_internalstates != null && m_internalstates.Contains(statenumber) == true) { controllers.AddRange(m_internalstates[statenumber].Controllers); } State state = new State(this, statenumber, textsection, controllers); return state; }
void ApplyState(State state) { if (state == null) throw new ArgumentNullException("state"); m_persistencemap.Clear(); if (state.Physics != Physics.Unchanged) Character.Physics = state.Physics; if (state.StateType != StateType.Unchanged) Character.StateType = state.StateType; if (state.MoveType != MoveType.Unchanged) Character.MoveType = state.MoveType; Int32? playercontrol = EvaluationHelper.AsInt32(m_character, state.PlayerControl, null); if (playercontrol != null) Character.PlayerControl = (playercontrol > 0) ? PlayerControl.InControl : PlayerControl.NoControl; Int32? animationnumber = EvaluationHelper.AsInt32(m_character, state.AnimationNumber, null); if (animationnumber != null) Character.SetLocalAnimation(animationnumber.Value, 0); Int32? spritepriority = EvaluationHelper.AsInt32(m_character, state.SpritePriority, null); if (spritepriority != null) Character.DrawOrder = spritepriority.Value; Int32? power = EvaluationHelper.AsInt32(m_character, state.Power, null); if (power != null) Character.BasePlayer.Power += power.Value; Vector2? velocity = EvaluationHelper.AsVector2(m_character, state.Velocity, null); if (velocity != null) Character.CurrentVelocity = velocity.Value; Boolean hitdefpersistance = EvaluationHelper.AsBoolean(m_character, state.HitdefPersistance, false); if (hitdefpersistance == false) { Character.OffensiveInfo.ActiveHitDef = false; Character.OffensiveInfo.HitPauseTime = 0; } Boolean movehitpersistance = EvaluationHelper.AsBoolean(m_character, state.MovehitPersistance, false); if (movehitpersistance == false) { Character.OffensiveInfo.MoveReversed = 0; Character.OffensiveInfo.MoveHit = 0; Character.OffensiveInfo.MoveGuarded = 0; Character.OffensiveInfo.MoveContact = 0; } Boolean hitcountpersistance = EvaluationHelper.AsBoolean(m_character, state.HitCountPersistance, false); if (hitcountpersistance == false) { Character.OffensiveInfo.HitCount = 0; Character.OffensiveInfo.UniqueHitCount = 0; } }
static void AddStateToCollection(KeyedCollection<Int32, State> collection, State state) { if (collection == null) throw new ArgumentNullException("collection"); if (state == null) throw new ArgumentNullException("state"); if (collection.Contains(state.Number) == true) { Log.Write(LogLevel.Warning, LogSystem.StateSystem, "Duplicate state #{0}. Discarding duplicate", state.Number); } else { collection.Add(state); } }