public int this[FlagTypes flag] { //I tried doing this with an array of generic enums but it caused problems so its a switch statement for now get { switch (flag) { case FlagTypes.CommonFlags: return((int)commonFlags); case FlagTypes.ValueFlags: return((int)valueFlags); default: return(0); } } set { switch (flag) { case FlagTypes.CommonFlags: commonFlags = (CommonFlags)value; break; case FlagTypes.ValueFlags: valueFlags = (ValueFlags)value; break; } } }
//ONLY real purporse of this class, to mark types, fields or methods //data stored directly inside assembly files public EventHandlerMark(CommonFlags a) { }
public bool CheckCommonFlag(CommonFlags flag) { return((flagData.commonFlags & flag) != CommonFlags.None); }
public void TurnCommonFlagsOn(CommonFlags flags) { flagData.commonFlags |= flags; }
public void TurnCommonFlagsOff(CommonFlags flags) { flagData.commonFlags &= ~flags; }
public FlagData(CommonFlags cf, ValueFlags vf) { commonFlags = cf; valueFlags = vf; }
public void TurnCommonFlagsOn(CommonFlags flags) { flagHandler.TurnCommonFlagsOn(flags); }
private void LateUpdate() { if (currentMove != null) { FlagData flagData = flagHandler.Flags; moveTime = moveTime == -1 ? 0 : moveTime + Time.deltaTime; //get the state of the flags tracked by the move CommonFlags moveFlags = (CommonFlags)currentMove.GetActiveFlags(moveTime, FlagTypes.CommonFlags); //activate the flags that are active according to the move //controllerFlags |= moveFlags; flagData.commonFlags |= moveFlags; //in the moveflags variable activate all flags not tracked by the move moveFlags |= (CommonFlags) ~currentMove.GetTrackedFlags(FlagTypes.CommonFlags); //turn off all flags not active acording to the move while leaving those not tracked by the move in their original state //controllerFlags &= moveFlags; flagData.commonFlags &= moveFlags; flagData.valueFlags = (ValueFlags)currentMove.GetActiveFlags(moveTime, FlagTypes.ValueFlags); flagHandler.Flags = flagData; if (entityController != null && flagHandler.ValueFlags != ValueFlags.None) { float gravityMod = 1.0f; if (!GetValue(ValueFlags.GravityModifier, out gravityMod)) { gravityMod = 1.0f; } entityController.GravityModifier = gravityMod; } if (listenToMoveMotion && entityController != null && flagHandler.ValueFlags != ValueFlags.None) { Vector2 targetVelocity = entityController.TargetVelocity; float val = 0; if (GetValue(ValueFlags.xVelocity, out val)) { targetVelocity.x = val * entityController.Facing; } if (GetValue(ValueFlags.yVelocity, out val)) { targetVelocity.y = val; } entityController.TargetVelocity = targetVelocity; } if (currentMove.EndMove(moveTime)) { bool exitConditions = true; foreach (LinkCondition c in currentMove.ExitConditions) { if (!CheckCondition(c)) { exitConditions = false; break; } } if (exitConditions) { StartMove(currentMove.ExitMove); //EnterGenericState(); } } } if (entityController != null) { entityController.AllowEntityCollision = (flagHandler.CommonFlags & CommonFlags.Dodgeing) == CommonFlags.None; } }
//ONLY real purporse of this class, to mark types, fields or methods //data stored directly inside assembly files public EventHandlerMark(CommonFlags a) { }