protected override MethodResult Get() { IndexedVar player = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedSphereHitbox: player", TranslateContext.IsGlobal); IndexedVar position = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedSphereHitbox: position", TranslateContext.IsGlobal); Element[] actions = ArrayBuilder <Element> .Build ( player.SetVariable((Element)Parameters[0]), position.SetVariable((Element)Parameters[1]) ); Element radius = (Element)Parameters[2]; Element eyePos = Element.Part <V_EyePosition>(player.GetVariable()); Element range = Element.Part <V_DistanceBetween>(eyePos, position.GetVariable()); Element direction = Element.Part <V_FacingDirectionOf>(player.GetVariable()); Element raycast = Element.Part <V_RayCastHitPosition>(eyePos, ( eyePos + direction * range ), new V_AllPlayers(), new V_Null(), new V_False() ); Element distance = Element.Part <V_DistanceBetween>(position.GetVariable(), raycast); Element compare = distance <= radius; return(new MethodResult(actions, compare)); }
protected override MethodResult Get() { IndexedVar array = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedRangeOfArray: array", TranslateContext.IsGlobal); Element[] actions = ArrayBuilder <Element> .Build ( array.SetVariable((Element)Parameters[0]) ); Element min = Element.Part <V_FirstOf>(Element.Part <V_SortedArray>(array.GetVariable(), new V_ArrayElement())); Element max = Element.Part <V_LastOf>(Element.Part <V_SortedArray>(array.GetVariable(), new V_ArrayElement())); return(new MethodResult(actions, max - min)); }
protected override MethodResult Get() { IndexedVar player = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedIsOnScreen: player", TranslateContext.IsGlobal); IndexedVar point = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedIsOnScreen: point", TranslateContext.IsGlobal); Element[] actions = ArrayBuilder <Element> .Build ( player.SetVariable((Element)Parameters[0]), point.SetVariable((Element)Parameters[1]) ); Element fov = (Element)Parameters[2]; Element los = Element.Part <V_IsInLineOfSight>(Element.Part <V_EyePosition>(player.GetVariable()), point.GetVariable()); Element angle = Element.Part <V_IsInViewAngle>(player.GetVariable(), point.GetVariable(), fov / 2); return(new MethodResult(actions, Element.Part <V_And>(los, angle))); }
protected override MethodResult Get() { IndexedVar point1 = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedHorizontalDistance: point1", TranslateContext.IsGlobal); IndexedVar point2 = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedHorizontalDistance: point2", TranslateContext.IsGlobal); Element[] actions = ArrayBuilder <Element> .Build ( point1.SetVariable((Element)Parameters[0]), point2.SetVariable((Element)Parameters[1]) ); Element x = Element.XOf(point1.GetVariable()) - Element.XOf(point2.GetVariable()); Element z = Element.ZOf(point1.GetVariable()) - Element.ZOf(point2.GetVariable()); Element sum = Element.Part <V_RaiseToPower>(x, Element.Num(2)) + Element.Part <V_RaiseToPower>(z, Element.Num(2)); return(new MethodResult(actions, Element.Part <V_SquareRoot>(sum))); }
protected override MethodResult Get() { IndexedVar player = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "SetHealth: player", TranslateContext.IsGlobal); IndexedVar health = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "SetHealth: health", TranslateContext.IsGlobal); Element[] actions = ArrayBuilder <Element> .Build ( player.SetVariable((Element)Parameters[0]), health.SetVariable((Element)Parameters[1]), Element.Part <A_SkipIf>(!(Element.Part <V_Health>(player.GetVariable()) < health.GetVariable()), Element.Num(2)), Element.Part <A_Heal>(player.GetVariable(), new V_Null(), health.GetVariable() - Element.Part <V_Health>(player.GetVariable())), Element.Part <A_Skip>(Element.Num(2)), Element.Part <A_SkipIf>(!(Element.Part <V_Health>(player.GetVariable()) > health.GetVariable()), Element.Num(1)), Element.Part <A_Damage>(player.GetVariable(), new V_Null(), Element.Part <V_Health>(player.GetVariable()) - health.GetVariable()) ); return(new MethodResult(actions, null)); }
protected override MethodResult Get() { IndexedVar array = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedSortedMedian: array", TranslateContext.IsGlobal); IndexedVar medianIndex = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedSortedMedian: medianIndex", TranslateContext.IsGlobal); Element length = Element.Part <V_CountOf>(array.GetVariable()); Element condition = Element.Part <V_Compare>(length % 2, EnumData.GetEnumValue(Operators.Equal), new V_Number(0)); Element consequent = (Element.Part <V_ValueInArray>(array.GetVariable(), medianIndex.GetVariable() - 0.5) + Element.Part <V_ValueInArray>(array.GetVariable(), medianIndex.GetVariable() + 0.5)) / 2; Element alternative = Element.Part <V_ValueInArray>(array.GetVariable(), medianIndex.GetVariable()); Element[] actions = ArrayBuilder <Element> .Build ( array.SetVariable(Element.Part <V_SortedArray>((Element)Parameters[0], new V_ArrayElement())), medianIndex.SetVariable((length + 1) / 2) ); return(new MethodResult(actions, Element.TernaryConditional(condition, consequent, alternative, false))); }
protected override MethodResult Get() { IndexedVar array = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedBlendedIndex: array", TranslateContext.IsGlobal); IndexedVar index = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedBlendedIndex: index", TranslateContext.IsGlobal); Element[] actions = ArrayBuilder <Element> .Build ( array.SetVariable((Element)Parameters[0]), index.SetVariable((Element)Parameters[1]) ); Element condition = Element.Part <V_Compare>(Element.Part <V_RoundToInteger>(index.GetVariable(), EnumData.GetEnumValue(Rounding.Down)), EnumData.GetEnumValue(Operators.Equal), index.GetVariable()); Element consequent = Element.Part <V_ValueInArray>(array.GetVariable(), index.GetVariable()); Element alt1 = Element.Part <V_ValueInArray>(array.GetVariable(), Element.Part <V_RoundToInteger>(index.GetVariable(), EnumData.GetEnumValue(Rounding.Down))) * Element.Part <V_Subtract>(index.GetVariable(), Element.Part <V_RoundToInteger>(index.GetVariable(), EnumData.GetEnumValue(Rounding.Down))); Element alt2 = Element.Part <V_ValueInArray>(array.GetVariable(), Element.Part <V_RoundToInteger>(index.GetVariable(), EnumData.GetEnumValue(Rounding.Up))) * (Element.Part <V_RoundToInteger>(index.GetVariable(), EnumData.GetEnumValue(Rounding.Up)) - index.GetVariable()); Element alternative = alt1 + alt2; return(new MethodResult(actions, Element.TernaryConditional(condition, consequent, alternative, false))); }
protected override MethodResult Get() { IndexedVar player = IndexedVar.AssignInternalVar(TranslateContext.VarCollection, Scope, "OptimisedEyeCastHitPosition: player", TranslateContext.IsGlobal); Element range = (Element)Parameters[1]; Element eyePos = Element.Part <V_EyePosition>(player.GetVariable()); Element direction = Element.Part <V_FacingDirectionOf>(player.GetVariable()); Element raycast = Element.Part <V_RayCastHitPosition>(eyePos, eyePos + direction * range, new V_Null(), new V_EventPlayer(), new V_False() ); Element[] actions = ArrayBuilder <Element> .Build ( player.SetVariable((Element)Parameters[0]) ); return(new MethodResult(actions, raycast)); }