Exemplo n.º 1
0
        public void GetMeta()
        {
            // Floor
            _scope.AddNativeMethod(new FuncMethodBuilder()
            {
                Name          = "Floor",
                Documentation = "Rounds the provided number down to the nearest integer.",
                ReturnType    = this,
                Action        = (actionSet, methodCall) => Element.RoundToInt(actionSet.CurrentObject, Rounding.Down)
            }.GetMethod());
            // Ceil
            _scope.AddNativeMethod(new FuncMethodBuilder()
            {
                Name          = "Ceil",
                Documentation = "Return the ceiling of the provided number.",
                ReturnType    = this,
                Action        = (actionSet, methodCall) => Element.RoundToInt(actionSet.CurrentObject, Rounding.Up)
            }.GetMethod());
            // Round
            _scope.AddNativeMethod(new FuncMethodBuilder()
            {
                Name          = "Round",
                Documentation = "Returns the provided number rounded to the nearest integer.",
                ReturnType    = this,
                Action        = (actionSet, methodCall) => Element.RoundToInt(actionSet.CurrentObject, Rounding.Nearest)
            }.GetMethod());
            // Absolute value
            _scope.AddNativeMethod(new FuncMethodBuilder()
            {
                Name          = "Abs",
                Documentation = "Returns the absolute value of the provided number. Also known as the value's distance to 0.",
                ReturnType    = this,
                Action        = (actionSet, methodCall) => Element.Abs(actionSet.CurrentObject)
            }.GetMethod());

            Operations.AddTypeOperation(new TypeOperation[] {
                new TypeOperation(TypeOperator.Add, this, this),                                  // Number + number
                new TypeOperation(TypeOperator.Subtract, this, this),                             // Number - number
                new TypeOperation(TypeOperator.Multiply, this, this),                             // Number * number
                new TypeOperation(TypeOperator.Divide, this, this),                               // Number / number
                new TypeOperation(TypeOperator.Modulo, this, this),                               // Number % number
                new TypeOperation(TypeOperator.Pow, this, this),
                new TypeOperation(TypeOperator.Multiply, _supplier.Vector(), _supplier.Vector()), // Number * vector
                new TypeOperation(TypeOperator.LessThan, this, _supplier.Boolean()),              // Number < number
                new TypeOperation(TypeOperator.LessThanOrEqual, this, _supplier.Boolean()),       // Number <= number
                new TypeOperation(TypeOperator.GreaterThanOrEqual, this, _supplier.Boolean()),    // Number >= number
                new TypeOperation(TypeOperator.GreaterThan, this, _supplier.Boolean()),           // Number > number
            });
            Operations.AddTypeOperation(AssignmentOperation.GetNumericOperations(this));
        }
Exemplo n.º 2
0
        public void Setup(SetupSelfContainedClass setup)
        {
            ParentArray = setup.AddObjectVariable(new InternalVar("ParentArray", _supplier.Any()));
            Pathmap     = setup.AddObjectVariable(new InternalVar("OriginMap", _pathfinderTypes.Pathmap.Instance));
            Destination = setup.AddObjectVariable(new InternalVar("Destination", _supplier.Vector()));

            setup.ObjectScope.AddNativeMethod(PathfindFunction);
            setup.ObjectScope.AddNativeMethod(Next);
        }
        public void GetMeta()
        {
            X = CreateInternalVar("X", "The X component of the vector.", _typeSupplier.Number());
            Y = CreateInternalVar("Y", "The Y component of the vector.", _typeSupplier.Number());
            Z = CreateInternalVar("Z", "The Z component of the vector.", _typeSupplier.Number());
            HorizontalAngle = CreateInternalVar("HorizontalAngle", "The horizontal angle of the vector.", _typeSupplier.Number());
            VerticalAngle   = CreateInternalVar("VerticalAngle", "The vertical angle of the vector.", _typeSupplier.Number());
            Magnitude       = CreateInternalVar("Magnitude", "The magnitude of the vector.", _typeSupplier.Number());
            Zero            = CreateInternalVar("Zero", "Equal to `Vector(0, 0, 0)`.", _typeSupplier.Vector(), Element.Vector(0, 0, 0), true);

            _deltinScript.GetComponent <StaticVariableCollection>().AddVariable(Zero.GetDefaultInstance(this));

            objectScope.AddNativeMethod(DistanceTo);
            objectScope.AddNativeMethod(CrossProduct);
            objectScope.AddNativeMethod(DotProduct);
            objectScope.AddNativeMethod(Normalize);
            objectScope.AddNativeMethod(DirectionTowards);
            objectScope.AddNativeMethod(FarthestPlayer);
            objectScope.AddNativeMethod(ClosestPlayer);
            objectScope.AddNativeMethod(IsInLineOfSight);
            objectScope.AddNativeMethod(Towards);
            objectScope.AddNativeMethod(AsLocalVector);
            objectScope.AddNativeMethod(AsWorldVector);

            Operations.AddTypeOperation(new TypeOperation[] {
                new TypeOperation(TypeOperator.Add, this, this),                        // Vector + vector
                new TypeOperation(TypeOperator.Subtract, this, this),                   // Vector - vector
                new TypeOperation(TypeOperator.Multiply, this, this),                   // Vector * vector
                new TypeOperation(TypeOperator.Divide, this, this),                     // Vector / vector
                new TypeOperation(TypeOperator.Multiply, _typeSupplier.Number(), this), // Vector * number
                new TypeOperation(TypeOperator.Divide, _typeSupplier.Number(), this),   // Vector / number
            });
            Operations.AddTypeOperation(new[] {
                new AssignmentOperation(AssignmentOperator.AddEqual, this),                        // += vector
                new AssignmentOperation(AssignmentOperator.SubtractEqual, this),                   // -= vector
                new AssignmentOperation(AssignmentOperator.MultiplyEqual, this),                   // *= vector
                new AssignmentOperation(AssignmentOperator.DivideEqual, this),                     // /= vector
                new AssignmentOperation(AssignmentOperator.MultiplyEqual, _typeSupplier.Number()), // *= number
                new AssignmentOperation(AssignmentOperator.DivideEqual, _typeSupplier.Number())    // /= number
            });
        }
Exemplo n.º 4
0
        public void GetMeta()
        {
            _objectScope = PlayerVariableScope.Child();
            AddSharedFunctionsToScope(_objectScope);

            AddFunc(new FuncMethodBuilder()
            {
                Name          = "IsButtonHeld",
                Parameters    = new[] { new CodeParameter("button", _supplier.EnumType("Button")) },
                ReturnType    = _supplier.Boolean(),
                Action        = (set, call) => Element.Part("Is Button Held", set.CurrentObject, call.ParameterValues[0]),
                Documentation = "Determines if the target player is holding a button."
            });
            AddFunc(new FuncMethodBuilder()
            {
                Name          = "IsCommunicating",
                Parameters    = new[] { new CodeParameter("communication", _supplier.EnumType("Communication")) },
                ReturnType    = _supplier.Boolean(),
                Action        = (set, call) => Element.Part("Is Communicating", set.CurrentObject, call.ParameterValues[0]),
                Documentation = "Determines if the target player is communicating."
            });
            AddFunc(new FuncMethodBuilder()
            {
                Name          = "Stat",
                Parameters    = new[] { new CodeParameter("stat", _supplier.EnumType("PlayerStat")) },
                ReturnType    = _supplier.Number(),
                Action        = (set, call) => Element.Part("Player Stat", set.CurrentObject, call.ParameterValues[0]),
                Documentation = "Provides a statistic of the specified Player (limited to the current match). Statistics are only gathered when the game is in progress. Dummy bots do not gather statistics.",
            });
            AddFunc(new FuncMethodBuilder()
            {
                Name          = "HeroStat",
                Parameters    = new[] { new CodeParameter("hero", _supplier.Hero()), new CodeParameter("stat", _supplier.EnumType("PlayerHeroStat")) },
                ReturnType    = _supplier.Number(),
                Action        = (set, call) => Element.Part("Player Hero Stat", set.CurrentObject, call.ParameterValues[0], call.ParameterValues[1]),
                Documentation = "Provides a statistic of the specified Player's time playing a specific hero (limited to the current match). Statistics are only gathered when the game is in progress. Dummy bots do not gather statistics.",
            });
            AddFunc("Position", _supplier.Vector(), set => Element.PositionOf(set.CurrentObject), "The position of the player.");
            AddFunc("EyePosition", _supplier.Vector(), set => Element.EyePosition(set.CurrentObject), "The position of the player's head.");
            AddFunc("Team", _supplier.Any(), set => Element.Part("Team Of", set.CurrentObject), "The team of the player.");
            AddFunc("Health", _supplier.Number(), set => Element.Part("Health", set.CurrentObject), "The health of the player.");
            AddFunc("MaxHealth", _supplier.Number(), set => Element.Part("Max Health", set.CurrentObject), "The maximum health of the player.");
            AddFunc("FacingDirection", _supplier.Vector(), set => Element.FacingDirectionOf(set.CurrentObject), "The facing direction of the player.");
            AddFunc("Hero", _supplier.Any(), set => Element.Part("Hero Of", set.CurrentObject), "The hero of the player.");
            AddFunc("IsHost", _supplier.Boolean(), set => Element.Compare(set.CurrentObject, Operator.Equal, Element.Part("Host Player")), "Determines if the player is the host.");
            AddFunc("IsAlive", _supplier.Boolean(), set => Element.Part("Is Alive", set.CurrentObject), "Determines if the player is alive.");
            AddFunc("IsDead", _supplier.Boolean(), set => Element.Part("Is Dead", set.CurrentObject), "Determines if the player is dead.");
            AddFunc("IsCrouching", _supplier.Boolean(), set => Element.Part("Is Crouching", set.CurrentObject), "Determines if the player is crouching.");
            AddFunc("IsDummy", _supplier.Boolean(), set => Element.Part("Is Dummy Bot", set.CurrentObject), "Determines if the player is a dummy bot.");
            AddFunc("IsFiringPrimary", _supplier.Boolean(), set => Element.Part("Is Firing Primary", set.CurrentObject), "Determines if the player is firing their primary weapon.");
            AddFunc("IsFiringSecondary", _supplier.Boolean(), set => Element.Part("Is Firing Secondary", set.CurrentObject), "Determines if the player is using their secondary attack.");
            AddFunc("IsInAir", _supplier.Boolean(), set => Element.Part("Is In Air", set.CurrentObject), "Determines if the player is in the air.");
            AddFunc("IsOnGround", _supplier.Boolean(), set => Element.Part("Is On Ground", set.CurrentObject), "Determines if the player is on the ground.");
            AddFunc("IsInSpawnRoom", _supplier.Boolean(), set => Element.Part("Is In Spawn Room", set.CurrentObject), "Determines if the player is in the spawn room.");
            AddFunc("IsMoving", _supplier.Boolean(), set => Element.Part("Is Moving", set.CurrentObject), "Determines if the player is moving.");
            AddFunc("IsOnObjective", _supplier.Boolean(), set => Element.Part("Is On Objective", set.CurrentObject), "Determines if the player is on the objective.");
            AddFunc("IsOnWall", _supplier.Boolean(), set => Element.Part("Is On Wall", set.CurrentObject), "Determines if the player is on a wall.");
            AddFunc("IsPortraitOnFire", _supplier.Boolean(), set => Element.Part("Is Portrait On Fire", set.CurrentObject), "Determines if the player's portrait is on fire.");
            AddFunc("IsStanding", _supplier.Boolean(), set => Element.Part("Is Standing", set.CurrentObject), "Determines if the player is standing.");
            AddFunc("IsUsingAbility1", _supplier.Boolean(), set => Element.Part("Is Using Ability 1", set.CurrentObject), "Determines if the player is using their ability 1.");
            AddFunc("IsUsingAbility2", _supplier.Boolean(), set => Element.Part("Is Using Ability 2", set.CurrentObject), "Determines if the player is using their ability 2.");
        }