public FixPoint GetEstimateBlockMovementTime() { if (m_blocks_movement_when_active) { FixPoint time = CastingTime; if (time > FixPoint.Zero) { return(FixPoint.Max(MIN_ESTIMATE_TIME, time)); } time = InflictTime; if (time > FixPoint.Zero) { return(FixPoint.Max(MIN_ESTIMATE_TIME, time)); } time = ExpirationTime; if (time > FixPoint.Zero) { return(FixPoint.Min(MAX_ESTIMATE_TIME, time)); } } else { if (!m_deactivate_when_moving && m_main_animation == null) { return(FixPoint.Zero); } else { return(MIN_ESTIMATE_TIME); } } return(MIN_ESTIMATE_TIME); }
FixPoint CalculateOverlapArea(GridNode node, ref Vector3FP downleft, ref Vector3FP upright) { Vector3FP center = Node2Position(node); FixPoint minx = FixPoint.Max(downleft.x, center.x - HALF_SQRT3_GRID_SIZE); FixPoint maxx = FixPoint.Min(upright.x, center.x + HALF_SQRT3_GRID_SIZE); if (minx > maxx) { return(FixPoint.Zero); } FixPoint minz = FixPoint.Max(downleft.z, center.z - THREE_QUARTERS_GRID_SIZE); FixPoint maxz = FixPoint.Min(upright.z, center.z + THREE_QUARTERS_GRID_SIZE); if (minz > maxz) { return(FixPoint.Zero); } return((maxx - minx) * (maxz - minz)); }
public virtual FixPoint Evaluate(IExpressionVariableProvider variable_provider) { Stack <FixPoint> stack = new Stack <FixPoint>(); FixPoint var1, var2, var3; int index = 0; int total_count = m_instructions.Count; while (index < total_count) { OperationCode op_code = (OperationCode)m_instructions[index]; ++index; switch (op_code) { case OperationCode.PUSH_NUMBER: stack.Push(FixPoint.CreateFromRaw(m_instructions[index])); ++index; break; case OperationCode.PUSH_VARIABLE: if (variable_provider != null) { var1 = variable_provider.GetVariable(m_variables[(int)m_instructions[index]], 0); stack.Push(var1); } else { stack.Push(FixPoint.Zero); } ++index; break; case OperationCode.NEGATE: var1 = stack.Pop(); stack.Push(-var1); break; case OperationCode.ADD: var2 = stack.Pop(); var1 = stack.Pop(); stack.Push(var1 + var2); break; case OperationCode.SUBTRACT: var2 = stack.Pop(); var1 = stack.Pop(); stack.Push(var1 - var2); break; case OperationCode.MULTIPLY: var2 = stack.Pop(); var1 = stack.Pop(); stack.Push(var1 * var2); break; case OperationCode.DIVIDE: var2 = stack.Pop(); var1 = stack.Pop(); stack.Push(var1 / var2); break; case OperationCode.SIN: var1 = stack.Pop(); stack.Push(FixPoint.Sin(var1)); break; case OperationCode.COS: var1 = stack.Pop(); stack.Push(FixPoint.Cos(var1)); break; case OperationCode.TAN: var1 = stack.Pop(); stack.Push(FixPoint.Tan(var1)); break; case OperationCode.SQRT: var1 = stack.Pop(); stack.Push(FixPoint.Sqrt(var1)); break; case OperationCode.MIN: var2 = stack.Pop(); var1 = stack.Pop(); stack.Push(FixPoint.Min(var1, var2)); break; case OperationCode.MAX: var2 = stack.Pop(); var1 = stack.Pop(); stack.Push(FixPoint.Max(var1, var2)); break; case OperationCode.CLAMP: var3 = stack.Pop(); var2 = stack.Pop(); var1 = stack.Pop(); stack.Push(FixPoint.Clamp(var1, var2, var3)); break; case OperationCode.EQUAL: var2 = stack.Pop(); var1 = stack.Pop(); if (var1 == var2) { stack.Push(FixPoint.One); } else { stack.Push(FixPoint.Zero); } break; case OperationCode.NOT_EQUAL: var2 = stack.Pop(); var1 = stack.Pop(); if (var1 != var2) { stack.Push(FixPoint.One); } else { stack.Push(FixPoint.Zero); } break; case OperationCode.GREATER: var2 = stack.Pop(); var1 = stack.Pop(); if (var1 > var2) { stack.Push(FixPoint.One); } else { stack.Push(FixPoint.Zero); } break; case OperationCode.GREATER_EQUAL: var2 = stack.Pop(); var1 = stack.Pop(); if (var1 >= var2) { stack.Push(FixPoint.One); } else { stack.Push(FixPoint.Zero); } break; case OperationCode.LESS: var2 = stack.Pop(); var1 = stack.Pop(); if (var1 < var2) { stack.Push(FixPoint.One); } else { stack.Push(FixPoint.Zero); } break; case OperationCode.LESS_EQUAL: var2 = stack.Pop(); var1 = stack.Pop(); if (var1 <= var2) { stack.Push(FixPoint.One); } else { stack.Push(FixPoint.Zero); } break; case OperationCode.AND: var2 = stack.Pop(); var1 = stack.Pop(); if (var1 != FixPoint.Zero && var2 != FixPoint.Zero) { stack.Push(FixPoint.One); } else { stack.Push(FixPoint.Zero); } break; case OperationCode.OR: var2 = stack.Pop(); var1 = stack.Pop(); if (var1 != FixPoint.Zero || var2 != FixPoint.Zero) { stack.Push(FixPoint.One); } else { stack.Push(FixPoint.Zero); } break; case OperationCode.NOT: var1 = stack.Pop(); if (var1 == FixPoint.Zero) { stack.Push(FixPoint.One); } else { stack.Push(FixPoint.Zero); } break; case OperationCode.AND_BITWISE: var2 = stack.Pop(); var1 = stack.Pop(); stack.Push(var1 & var2); break; case OperationCode.OR_BITWISE: var2 = stack.Pop(); var1 = stack.Pop(); stack.Push(var1 | var2); break; case OperationCode.CONDITIONAL_EXPRESSION: var3 = stack.Pop(); var2 = stack.Pop(); var1 = stack.Pop(); if (var1 != FixPoint.Zero) { stack.Push(var2); } else { stack.Push(var3); } break; default: break; } } return(stack.Pop()); }