Exemple #1
0
 public void ClearModel()
 {
     _currentEntity?.Detach();
     _currentEntity?.Delete();
     _currentEntity = null;
     Client.Player.PlayerPed.IsVisible = true;
 }
Exemple #2
0
        public void BuildEntity(Entity entity, params object[] args)
        {
            string textureFile = args[0] as string;
            int?   x           = args[1] as int?;
            int?   y           = args[2] as int?;

            string filePath = ".\\Graphics\\Backgrounds\\" + textureFile;

            StaticGraphic staticGraphic = _componentFactory.Create <StaticGraphic>();

            staticGraphic.Scrolls = true;
            staticGraphic.Texture = _content.Load <Texture2D>(filePath);
            entity.AddComponent(staticGraphic);

            Position position = _componentFactory.Create <Position>();

            position.X = x ?? 0;
            position.Y = y ?? 0;
            entity.AddComponent(position);

            Entity existingBackground = EntitySystem.BlackBoard.GetEntry <Entity>("Background");

            existingBackground?.Delete();

            EntitySystem.BlackBoard.SetEntry("Background", entity);
        }
        public override void Process(Entity e)
        {
            Animation a = e.GetComponent<Animation>();

            if (a.Type == AnimationType.None)
            {
                e.Delete();
            }
        }
        public override void Process(Entity e)
        {
            Expires expires = expiresMapper.Get(e);
            expires.ReduceLifeTime(world.ElapsedTime);

            if (expires.IsExpired) {
                e.Delete();
            }
        }
 private void EndAttachment()
 {
     // Delete the web helpers.
     _webShooterRope?.Delete();
     _webShooterHelper?.Delete();
     Profile.LocalUser.Task.ClearAnimation("amb@code_human_wander_texting@male@base", "static");
     Profile.LocalUser.Task.ClearAnimation("move_crouch_proto", "idle_intro");
     GameWaiter.Wait(200);
 }
        public override void Process(Entity e)
        {
            if (!e.HasComponent<AI>())
                return;

            AI ai = e.GetComponent<AI>();

            bool behavior;

            if (ai.Target != null)
            {
                if (World.EntityManager.GetEntity((ai.Target.UserData as Entity).Id) == null)
                    ai.Target = null;
                else if (!(!ai.Recalculate && ai.Calculated) && ai.Target != null && (ai.Target.UserData as Entity) != null && !(behavior = ai.Behavior(ai.Target))) //Run ai behavior, if behavior returns true look for new target.
                {
                    ai.Calculated = true;

                    if (ai.Target == null && e.Group != "Players" && e.Group != "Structures" && !e.Tag.Contains("Cannon"))
                    {
                        if (e.HasComponent<Health>())
                            e.GetComponent<Health>().SetHealth(null, 0);
                        else
                            e.Delete();
                    }

                    return;
                }
            }

            ai.Calculated = true;
            ai.Target = _FindNewTarget(ai, e.GetComponent<Body>());

            if (ai.Target == null && e.Group != "Players" && e.Group != "Structures" && !e.Tag.Contains("Boss"))
            {
                if (e.HasComponent<Health>())
                    e.GetComponent<Health>().SetHealth(null, 0);
                else
                    e.Delete();
            }
            else if (ai.Target == null && e.Group == "Players")
                ai.Behavior(null);

            e.Refresh();
        }
Exemple #7
0
 public static void DamageTarget(Entity user, Entity target, int damage, double hitSuccess = 1)
 {
     EntityCreator.CreateDamageInfo(target, damage, hitSuccess);
     BattleStats stats = target.GetComponent<BattleStats>();
     stats.Health.Decrease(damage);
     if (stats.IsDead && !target.GetComponent<Group>().IsHero)
     {
         target.Delete();
     }
 }
Exemple #8
0
        /// <summary>
        ///     Here's where the script stops.
        /// </summary>
        public override void Stop()
        {
            // Delete the helper object.
            _helperObj?.Delete();

            // Re-enable player pain audio.
            Profile.LocalUser.DisablePainAudio(false);

            // Clear our anim once we stop
            Profile.LocalUser.Task.ClearAnimation("move_fall", "fall_high");
        }
        public override void Process(Entity e)
        {
            if (!e.HasComponent<FadingText>())
                return;

            FadingText f = e.GetComponent<FadingText>();

            f.Update(world.Delta);

            if (f.Fraction() <= 0)
            {
                e.Delete();
            }
        }
Exemple #10
0
        public void TestEntity_Constructor_TypeId_ValidTypeId( )
        {
            long typeId = EntityIdentificationCache.GetId(new EntityAlias("core", "type"));

            Entity entity = null;

            try
            {
                entity = new Entity(typeId);

                entity.Save( );
            }
            finally
            {
                entity?.Delete( );
            }
        }
        public override void Process(Entity e)
        {
            try
            {
                if (!e.HasComponent<Bullet>())
                    return;
            }
            catch
            {
                return;
            }

            Particle particle = particleMapper.Get(e);
            Bullet bullet = bulletMapper.Get(e);

            world.RayCast(
                delegate(Fixture fix, Vector2 point, Vector2 normal, float fraction) //On hit
                {
                    ++bullet.collisionChecked;
                    if (fix.Body.UserData is Entity)
                    {
                        if ((fix.Body.UserData as Entity).HasComponent<Health>()
                            && (fix.Body.UserData as Entity).Group == bullet.DamageGroup)
                        { //Do damage
                            (fix.Body.UserData as Entity).GetComponent<Health>().SetHealth(bullet.Firer,
                                (fix.Body.UserData as Entity).GetComponent<Health>().CurrentHealth - bullet.Damage);
                            e.Delete(); //Remove bullet

                            if (bullet.OnBulletHit != null)
                            {
                                //Do bullet effects here........... Maybe a call back?{
                                bullet.OnBulletHit(fix.Body.UserData as Entity);
                            }

                            if (!(fix.Body.UserData as Entity).HasComponent<Health>() || (fix.Body.UserData as Entity).GetComponent<Health>().IsAlive)
                                world.CreateEntity("Explosion", 0f, particle.Position, fix.Body.UserData, 1, fix.Body.LinearVelocity, fix.Body.UserData).Refresh();
                        }
                    }
                    return 0;
                }, particle.Position, particle.Position + particle.LinearVelocity * new Vector2(World.Delta * .001f));
        }
Exemple #12
0
        public void Tick(TickContext context)
        {
            _despawnTimer.Tick(context.DeltaTime);
            if (_despawnTimer.Completed)
            {
                Entity.Delete();
                return;
            }

            if (FlightSpaces == null)
            {
                return;
            }

            var location = Transform.Location;
            // Get every obstacle within 5 units of the node.
            var obstacle = FlightSpaces.ObstacleSpace.GetNearby(location, 5f);
            foreach (var entity in obstacle)
            {
                var pos = entity.Get<Transform>().Location;
                var distance = (location - pos).Length();
                var radius = entity.Get<IObstacle>()?.Radius ?? 1f;
                if (distance < Radius + radius)
                {
                    if (entity.Has<IProjectileCollider>())
                    {
                        entity.Get<IProjectileCollider>().OnHit(Entity, this);
                        EntityDidHit(entity);
                    }
                }
            }
            foreach (var entity in FlightSpaces.ShipSpace.GetNearby(location, 5f))
            {
                var node = entity.Get<FlightNode>();
                if (!node.Active || node.ShipGuid == ShipGuid)
                {
                    continue;
                }
                var pos = node.GlobalLocation;
                var distance = (location - pos).Length();
                if (distance < 1 + Radius)
                {
                    if (entity.Has<IProjectileCollider>())
                    {
                        entity.Get<IProjectileCollider>().OnHit(Entity, this);
                        EntityDidHit(entity);
                    }
                }
            }
            if (HitProjectiles)
            {
                foreach (var entity in FlightSpaces.ProjectileSpace.GetNearby(location, 5f))
                {
                    if (entity == this.Entity)
                    {
                        continue;
                    }
                    var pos = entity.Get<Transform>().Location;
                    var distance = (location - pos).Length();
                    var radius = entity.Get<ProjectileBase>()?.Radius ?? 1f;
                    if (distance < Radius + radius)
                    {
                        if (entity.Has<IProjectileCollider>())
                        {
                            entity.Get<IProjectileCollider>().OnHit(Entity, this);
                            EntityDidHit(entity);
                        }
                    }
                }
            }

            UpdatePosition(context);

        }
Exemple #13
0
        private void AdjustIntensity(Entity beamEntity, BeamComponent beamComponent)
        {
            // adjust intensity
            if (beamComponent.Intensity >= 1 && beamComponent.Beam.Lifetime > 0)
            {
                beamComponent.Age += (EntityWorld.Delta / 1000f);
                if (beamComponent.Age > beamComponent.Beam.Lifetime)
                {
                    beamComponent.IsPowered = false;
                }
            }

            if (beamComponent.IsPowered)
            {
                if (beamComponent.Beam.IntensityFadeInTime > 0)
                {
                    beamComponent.Intensity += (EntityWorld.Delta / beamComponent.Beam.IntensityFadeInTime) / 1000f;
                    if (beamComponent.Intensity > 1)
                        beamComponent.Intensity = 1;
                }
                else
                {
                    beamComponent.Intensity = 1;
                }
            }
            else
            {
                if (beamComponent.Beam.IntensityFadeOutTime > 0)
                {
                    beamComponent.Intensity -= (EntityWorld.Delta / beamComponent.Beam.IntensityFadeOutTime) / 1000f;
                    if (beamComponent.Intensity < 0)
                        beamComponent.Intensity = 0;
                }
                else
                {
                    beamComponent.Intensity = 0;
                }

                if (beamComponent.Intensity <= 0)
                {
                    beamEntity.Delete();
                }
            }
        }
 public override void Process(Entity entity)
 {
     //save command
     entity.Delete();
 }
Exemple #15
0
        /// <summary>
        /// 删除记录
        /// </summary>
        /// <param name="strIDs">删除的ID,用','连接</param>
        /// <param name="bActual">物理删除还是逻辑删除</param>
        /// <returns></returns>
        public static bool Delete(string strIDs, bool bActual)
        {
            string strSql = string.Format("[ID] IN ({0})", strIDs);

            return(Entity.Delete(Position.TableName, strSql, bActual) > 0);
        }
Exemple #16
0
    private static IEnumerator doEmote(Entity player, string emote)
    {
        if (player.GetField <bool>("isEmoting"))
        {
            yield break;
        }
        if (!player.GetField <bool>("emoteMenuOpen"))
        {
            yield break;
        }
        if (!player.IsOnGround() || player.IsOnLadder())
        {
            yield break;
        }

        player.SetField("isEmoting", true);
        destroyEmoteMenu(player);
        player.SetField("emoteMenuOpen", false);


        string primaryWeapon = player.GetCurrentPrimaryWeapon();

        /*
         * int primaryAmmoClip = player.GetWeaponAmmoClip(primaryWeapon);
         * int primaryAmmoStock = player.GetWeaponAmmoStock(primaryWeapon);
         * player.TakeWeapon(primaryWeapon);
         */
        bool hasHackWeapon = player.HasWeapon(hackWeapon) && player.GetWeaponAmmoClip(hackWeapon) > 0;//Since we can't directly set player.tag_stowed_back, we are using a 'hackWeapon' to hide the tag with a weapon that naturally does this

        player.GiveWeapon(hackWeapon);
        player.SetWeaponAmmoClip(hackWeapon, 0);
        player.SwitchToWeapon(hackWeapon);

        //player.DisableWeapons();
        player.DisableOffhandWeapons();
        player.DisableWeaponSwitch();
        player.DisableWeaponPickup();
        player.SetMoveSpeedScale(0);
        player.AllowJump(false);
        player.AllowSprint(false);

        string stance = player.GetStance();

        player.SetStance("stand");
        StartAsync(monitorPlayerStance(player));

        Entity clone = Spawn("script_model", player.Origin);

        clone.SetModel(player.Model);
        clone.Angles = player.Angles;
        Entity cloneHead = Spawn("script_model", clone.Origin);

        cloneHead.SetModel(player.GetAttachModelName(0));
        cloneHead.LinkTo(clone, "j_spine4", Vector3.Zero, Vector3.Zero);

        //player.HideAllParts();
        //Hide specific parts for hitbox
        player.HidePart("pelvis");
        player.HidePart("j_hip_ri");
        player.HidePart("j_hip_le");
        player.HidePart("back_low");
        player.HidePart("back_mid");
        player.HidePart("j_wristtwist_le");
        player.HidePart("j_wristtwist_ri");
        player.HidePart("j_head");
        player.HidePart("j_eyeball_ri");
        player.HidePart("j_eyeball_le");
        player.HidePart("j_jaw");

        //play current anims
        clone.ScriptModelPlayAnim("pt_stand_pullout_pose");
        cloneHead.ScriptModelPlayAnim("pt_stand_pullout_pose");

        player.SetClientDvar("camera_thirdPerson", 1);
        player.SetClientDvar("camera_thirdPersonOffset", new Vector3(0, 0, 0));
        Entity cameraLerper = Spawn("script_model", Vector3.Zero);

        cameraLerper.SetModel("tag_origin");
        cameraLerper.SetField("time", 0);
        OnInterval(50, () => lerpThirdPersonCamera(player, cameraLerper));

        cameraLerper.MoveTo(new Vector3(-120, 0, 14), 1);

        yield return(Wait(1));

        player.Notify("emote_playing");

        //Reset player origin if they were running and drifted off when activating
        player.SetOrigin(clone.Origin);

        //play emote
        clone.ScriptModelPlayAnim(emote);
        cloneHead.ScriptModelPlayAnim(emote);

        yield return(player.WaitTill_notify_or_timeout("damage", 5));

        cameraLerper.SetField("time", 0);
        OnInterval(50, () => lerpThirdPersonCamera(player, cameraLerper));

        cameraLerper.MoveTo(Vector3.Zero, 1);

        yield return(Wait(1));

        player.Notify("emote_stop");

        player.SetClientDvar("camera_thirdPerson", 0);
        player.SetClientDvar("camera_thirdPersonOffset", new Vector3(-120, 0, 14));
        player.SetPlayerAngles(clone.Angles);
        player.SetStance(stance);
        player.ShowAllParts();
        cloneHead.Unlink();
        cloneHead.Delete();
        clone.Delete();
        cameraLerper.Delete();
        //player.EnableWeapons();
        player.EnableOffhandWeapons();
        player.EnableWeaponSwitch();
        player.EnableWeaponPickup();
        player.SetMoveSpeedScale(1);
        player.AllowJump(true);
        player.AllowSprint(true);
        if (hasHackWeapon)
        {
            player.SetWeaponAmmoClip(hackWeapon, 1);//Restore ammo if they had it
        }
        else
        {
            player.TakeWeapon(hackWeapon);
        }
        player.SwitchToWeaponImmediate(primaryWeapon);
        player.SetField("isEmoting", false);
    }
        [RunWithoutTransaction]         // Can't be in a transaction as it takes too long
        public void SendMany(int numberToSend)
        {
            Random rand = new Random();

            TwilioNotifier notifier     = null;
            List <Person>  people       = null;
            Notification   notification = null;

            try
            {
                notifier = new TwilioNotifier()
                {
                    Name             = "LoopbackApiTest.Notify " + DateTime.UtcNow,
                    TpAccountSid     = rand.Next().ToString(),
                    TpAuthToken      = rand.Next().ToString(),
                    TpSendingNumber  = rand.Next().ToString(),
                    TpEnableTestMode = true
                };
                notifier.Save();

                people = new List <Person>();

                var mobilePhoneField = Factory.ScriptNameResolver.GetInstance("Mobile phone", StringField.StringField_Type.Id);

                for (int i = 0; i < numberToSend; i++)
                {
                    var person = new Person {
                        Name = "LoopbackApiTest.Notify " + DateTime.UtcNow
                    };

                    var mobileNumber = rand.Next().ToString();
                    person.SetField(mobilePhoneField, mobileNumber);
                    people.Add(person);
                }

                Entity.Save(people);

                notification = new Notification {
                    NMessage = "TestMessage", NAcceptRepliesUntil = DateTime.UtcNow.AddDays(1)
                };
                notification.Save();

                TwilioRouter.Instance.Send(notifier, notification, people, true);

                var results = Entity.Get <Notification>(notification.Id).SendRecords;
                Assert.That(results, Is.Not.Null);
                Assert.That(results.Count, Is.EqualTo(numberToSend));

                foreach (var result in results)
                {
                    Assert.That(result.SrErrorMessage, Is.Null);
                }
            }
            finally
            {
                notifier?.Delete();
                if (people.Any())
                {
                    Entity.Delete(people.Select(p => p.Id));
                }
                notification?.Delete();
            }
        }
Exemple #18
0
        private static void Init()
        {
            Events.DSRLoad.Add((sender, args) =>
            {
                if (args.TryGetOpt("custom_gametype", out var value))
                {
                    ServerStr.ReportedGameType = value;

                    Log.Debug(value);
                }
            });

            Config.Load();
            Utils.SetObjectiveText();

            #region Commands
            // SETFLY
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "setfly",
                                    argTypes: new[] { SmartParse.Player, SmartParse.Boolean },
                                    action : delegate(Entity sender, object[] args)
            {
                Entity ent = args[0] as Entity;
                bool state = (bool)args[1];

                ent.SetField("EnableFly", state);

                if (state)
                {
                    if (!ent.IsFieldTrue("InitializedFly"))
                    {
                        Utils.InitializeFly(ent);
                    }

                    Utils.DoFly(ent);
                }

                sender.Tell($"%nFly for %p{ent.Name} %nset to %i{state}");
            },
                                    usage: "!setfly <player> <state>",
                                    permission: "setfly",
                                    description: "Enables or disables fly for the specified player"));

            // MYFLY
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "myfly",
                                    argTypes: new[] { SmartParse.Boolean },
                                    action : delegate(Entity sender, object[] args)
            {
                bool state = (bool)args[0];

                sender.SetField("EnableFly", state);

                if (state)
                {
                    if (!sender.IsFieldTrue("InitializedFly"))
                    {
                        Utils.InitializeFly(sender);
                    }

                    Utils.DoFly(sender);
                }

                sender.Tell($"%nFly set to %i{state}");
            },
                                    usage: "!myfly <state>",
                                    permission: "myfly",
                                    description: "Enables or disables fly"));

            // UNLIMITEDAMMO
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "unlimitedammo",
                                    argTypes: new[] { SmartParse.Boolean },
                                    action : delegate(Entity sender, object[] args)
            {
                bool state = (bool)args[0];

                sender.SetField("UnlimitedAmmo", state);

                if (state)
                {
                    BaseScript.OnInterval(1, () =>
                    {
                        if (!sender.IsFieldTrue("UnlimitedAmmo"))
                        {
                            return(false);
                        }

                        sender.SetWeaponAmmoClip(sender.CurrentWeapon, int.MaxValue, "right");
                        sender.SetWeaponAmmoClip(sender.CurrentWeapon, int.MaxValue, "left");
                        sender.SetWeaponAmmoStock(sender.CurrentWeapon, int.MaxValue);

                        return(true);
                    });
                }

                sender.Tell($"%nUnlimited ammo set to %i{state}");
            },
                                    usage: "!unlimitedammo <state>",
                                    permission: "unlimitedammo",
                                    description: "Enables or disables unlimited ammo"));

            // UNLIMITEDAMMOWITHRELOAD
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "unlimitedammowithreload",
                                    argTypes: new[] { SmartParse.Boolean },
                                    action : delegate(Entity sender, object[] args)
            {
                bool state = (bool)args[0];

                sender.SetField("UnlimitedAmmoReload", state);

                if (state)
                {
                    BaseScript.OnInterval(1, () =>
                    {
                        if (!sender.IsFieldTrue("UnlimitedAmmoReload"))
                        {
                            return(false);
                        }

                        sender.SetWeaponAmmoStock(sender.CurrentWeapon, int.MaxValue);

                        return(true);
                    });
                }

                sender.Tell($"%nUnlimited ammo with reload set to %i{state}");
            },
                                    usage: "!unlimitedammowithreload <state>",
                                    permission: "unlimitedammowithreload",
                                    description: "Enables or disables unlimited ammo with reload"));

            // UNLIMITEDGRENADES
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "unlimitedgrenades",
                                    argTypes: new[] { SmartParse.Boolean },
                                    action : delegate(Entity sender, object[] args)
            {
                bool state = (bool)args[0];

                sender.SetField("UnlimitedGrenades", state);

                if (state)
                {
                    Events.GrenadeFire.Add((sender1, arguments) =>
                    {
                        if (arguments.Player.IsFieldTrue("UnlimitedGrenades"))
                        {
                            arguments.Player.GiveWeapon(arguments.Grenade);
                        }
                    });
                }

                sender.Tell($"%nUnlimited grenades set to %i{state}");
            },
                                    usage: "!unlimitedgrenades <state>",
                                    permission: "unlimitedgrenades",
                                    description: "Enables or disables unlimited grenades"));

            // AIMBOT
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "myaimbot",
                                    argTypes: new[] { SmartParse.Boolean },
                                    action : delegate(Entity sender, object[] args)
            {
                bool state = (bool)args[0];

                sender.SetField("EnableAimbot", state);

                if (state)
                {
                    Utils.DoAimbot(sender);
                }

                sender.Tell($"%nAimbot set to %i{state}");
            },
                                    usage: "!myaimbot <state>",
                                    permission: "myaimbot",
                                    description: "Enables or disables aimbot"));

            // SILENTAIM
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "mysilentaim",
                                    argTypes: new[] { SmartParse.Boolean },
                                    action : delegate(Entity sender, object[] args)
            {
                bool state = (bool)args[0];

                sender.SetField("EnableSilentAim", state);
                Utils.SetupSilentAim();

                sender.Tell($"%nSilentAim set to %i{state}");
            },
                                    usage: "!mysilentaim <state>",
                                    permission: "mysilentaim",
                                    description: "Enables or disables silentaim"));

            // AIMASSIST
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "myaimassist",
                                    argTypes: new[] { SmartParse.Boolean },
                                    action : delegate(Entity sender, object[] args)
            {
                bool state = (bool)args[0];

                sender.SetField("EnableAimAssist", state);

                if (state)
                {
                    Utils.DoAimAssist(sender);
                }

                sender.Tell($"%nAimAssist set to %i{state}");
            },
                                    usage: "!myaimassist <state>",
                                    permission: "myaimassist",
                                    description: "Enables or disables aimassist"));

            // AKIMBO
            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "akimbo",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                Utils.AkimboPrimary(sender);
                sender.Tell($"%nAkimbo primary enabled");
            },
                                    usage: "!akimbo",
                                    permission: "akimbo",
                                    description: "Enables akimbo primary"));

            // TPHERE
            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "akimbomode",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                Events.PlayerSpawned.Add((sender1, args1) =>
                {
                    Utils.AkimboPrimary(sender1 as Entity);
                });

                Events.PlayerRespawned.Add((sender1, args1) =>
                {
                    Utils.AkimboPrimary(sender1 as Entity);
                });

                sender.Tell($"%nAkimbomode enabled");
            },
                                    usage: "!akimbomode",
                                    permission: "akimbomode",
                                    description: "Enables akimbomode"));

            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "tphere",
                                    argTypes: new[] { SmartParse.Player },
                                    action : delegate(Entity sender, object[] args)
            {
                Entity ent = args[0] as Entity;

                ent.SetOrigin(sender.GetOrigin());

                ent.Tell($"%nYou have been teleported to %p{sender.Name}");
                sender.Tell($"%p{ent.Name} %nhas been teleported to you");
            },
                                    usage: "!tphere <player>",
                                    permission: "tphere",
                                    description: "Teleports a player to you"));

            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "tppoint",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                bool fix = false;

                sender.GiveWeapon("uav_strike_marker_mp");
                BaseScript.AfterDelay(100, () => sender.SwitchToWeaponImmediate("uav_strike_marker_mp"));

                Action <object, WeaponFiredArgs> hook = (obj, arg) =>
                {
                    Entity ent    = arg.Player;
                    string weapon = arg.Weapon;

                    if (weapon != "uav_strike_marker_mp" || ent != sender)
                    {
                        return;
                    }

                    int LaserFX           = GSCFunctions.LoadFX("misc/laser_glow");
                    Vector3 playerForward = ent.GetTagOrigin("tag_weapon_right") + GSCFunctions.AnglesToForward(ent.GetPlayerAngles()) * 10000;
                    Entity refObject      = GSCFunctions.Spawn("script_model", ent.GetTagOrigin("tag_weapon_tight"));

                    refObject.SetField("angles", ent.GetPlayerAngles());
                    refObject.SetModel("com_plasticcase_beige_big");
                    refObject.MoveTo(playerForward, 5f);
                    refObject.Hide();

                    ent.TakeWeapon("uav_strike_marker_mp");

                    BaseScript.OnInterval(10, () =>
                    {
                        Vector3 endLoc = refObject.GetOrigin() + GSCFunctions.AnglesToForward(refObject.GetField <Vector3>("angles")) * 100;

                        if (!GSCFunctions.SightTracePassed(refObject.GetOrigin(), endLoc, false, ent))
                        {
                            Entity fx = GSCFunctions.SpawnFX(LaserFX, refObject.Origin);
                            sender.SetOrigin(refObject.GetOrigin());
                            fix = true;

                            GSCFunctions.TriggerFX(fx);
                            sender.Tell($"%nYou have been teleported to %p{refObject.Origin.ToString()}");
                            refObject.Notify("death");
                            BaseScript.AfterDelay(500, () => fx.Delete());

                            return(false);
                        }

                        return(true);
                    });
                };

                Events.WeaponFired.Add(hook);

                BaseScript.OnInterval(100, () =>
                {
                    if (fix)
                    {
                        Events.WeaponFired.Remove(hook);

                        return(false);
                    }

                    return(true);
                });
            },
                                    usage: "!tppoint",
                                    permission: "tppoint",
                                    description: "Teleports you to a point"));

            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "giveallperks",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                List <string> perks = new List <string>()
                {
                    "specialty_longersprint",
                    "specialty_fastreload",
                    "specialty_scavenger",
                    "specialty_blindeye",
                    "specialty_paint",
                    "specialty_hardline",
                    "specialty_coldblooded",
                    "specialty_quickdraw",
                    "specialty_blastshield",
                    "specialty_detectexplosive",
                    "specialty_autospot",
                    "specialty_bulletaccuracy",
                    "specialty_quieter",
                    "specialty_stalker",
                    "specialty_copycat",
                    "specialty_juiced",
                    "specialty_grenadepulldeath",
                    "specialty_finalstand",
                    "specialty_revenge",
                    "specialty_stopping_power",
                    "specialty_c4death",
                    "specialty_uav"
                };

                sender.ClearPerks();

                foreach (string s in perks)
                {
                    sender.SetPerk(s, true, true);
                }

                sender.Tell(perks.Where(x => !sender.HasPerk(x)).Condense());
            },
                                    usage: "!giveallperks",
                                    permission: "giveallperks",
                                    description: "Gives you all perks"));

            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "washingmachine",
                                    argTypes: new[] { SmartParse.String },
                                    action : delegate(Entity sender, object[] args)
            {
                switch (args[0] as string)
                {
                case "random":
                    Random rand = new Random();

                    BaseScript.OnInterval(1, () =>
                    {
                        int num = rand.Next(10);

                        switch (num)
                        {
                        case 1:
                            sender.SetPlayerAngles(new Vector3(sender.GetPlayerAngles().X, sender.GetPlayerAngles().Y, sender.GetPlayerAngles().Z + 1));
                            break;

                        case 2:
                            sender.SetPlayerAngles(new Vector3(sender.GetPlayerAngles().X, sender.GetPlayerAngles().Y, sender.GetPlayerAngles().Z - 1));
                            break;

                        case 3:
                            sender.SetPlayerAngles(new Vector3(sender.GetPlayerAngles().X, sender.GetPlayerAngles().Y, sender.GetPlayerAngles().Z + 50));
                            break;

                        case 4:
                            sender.SetPlayerAngles(new Vector3(sender.GetPlayerAngles().X, sender.GetPlayerAngles().Y, sender.GetPlayerAngles().Z - 50));
                            break;

                        case 5:
                            sender.SetPlayerAngles(new Vector3(sender.GetPlayerAngles().X, sender.GetPlayerAngles().Y, sender.GetPlayerAngles().Z - 100));
                            break;

                        case 6:
                            sender.SetPlayerAngles(new Vector3(sender.GetPlayerAngles().X, sender.GetPlayerAngles().Y, sender.GetPlayerAngles().Z + 100));
                            break;

                        default:
                            sender.SetPlayerAngles(new Vector3(sender.GetPlayerAngles().X, sender.GetPlayerAngles().Y, sender.GetPlayerAngles().Z + 3));
                            break;
                        }
                        return(true);
                    });
                    break;
                }
            },
                                    usage: "!washingmachine <string>",
                                    permission: "washingmachine",
                                    description: "Enables washing machine"));


            // GIVEWEP
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "givewep",
                                    argTypes: new[] { SmartParse.String },
                                    action : delegate(Entity sender, object[] args)
            {
                string wep = args[0] as string;

                sender.GiveWeapon(wep);
                sender.SetWeaponAmmoClip(wep, int.MaxValue);
                sender.SetField("Allow_Weapon_Name", wep);
                sender.SetField("Allow_Grenade_Name", wep);
                BaseScript.AfterDelay(100, () => sender.SwitchToWeaponImmediate(wep));

                sender.Tell($"%nYou have been given %p{wep}");
            },
                                    usage: "!givewep <weapon>",
                                    permission: "givewep",
                                    description: "Gives you the specified weapon"));

            // AC130
            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "ac130",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                sender.GiveWeapon("ac130_105mm_mp");
                sender.GiveWeapon("ac130_40mm_mp");
                sender.GiveWeapon("ac130_25mm_mp");
                BaseScript.AfterDelay(100, () => sender.SwitchToWeaponImmediate("ac130_105mm_mp"));

                sender.Tell($"%nYou have been given ac130");
            },
                                    usage: "!ac130",
                                    permission: "ac130",
                                    description: "Gives you AC130"));

            // AC130
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "missilestrike",
                                    argTypes: new[] { SmartParse.Integer },
                                    action : delegate(Entity sender, object[] args)
            {
                int times = (int)args[0];

                sender.Tell($"%nAirstrike confirmed. Sending %h1{times} %nmissiles");

                BaseScript.OnInterval(400, () =>
                {
                    Utils.MissileStrike(sender);

                    if (times > 0)
                    {
                        times--;

                        return(true);
                    }

                    return(false);
                });
            },
                                    usage: "!missilestrike <time>",
                                    permission: "missilestrike",
                                    description: "Sends a missile strike"));

            // TAKEALLWEPS
            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "takeallweps",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                sender.TakeAllWeapons();
                sender.Tell($"%nAll weapons taken");
            },
                                    usage: "!takeallweps",
                                    permission: "takeallweps",
                                    description: "Takes all weapons"));

            // CRASH
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "crash",
                                    argTypes: new[] { SmartParse.UnimmunePlayer },
                                    action : delegate(Entity sender, object[] args)
            {
                Entity ent = args[0] as Entity;

                Utils.CrashPlayer(ent);
                sender.Tell($"%p{ent.Name} %nhas been crashed");
            },
                                    usage: "!crash <player>",
                                    permission: "crash",
                                    description: "Crashes the players client"));

            // SPAWNPLAYER
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "spawnplayer",
                                    argTypes: new[] { SmartParse.UnimmunePlayer },
                                    action : delegate(Entity sender, object[] args)
            {
                Entity ent = args[0] as Entity;

                ent.Notify("menuresponse", "team_marinesopfor", "spectator");
                BaseScript.AfterDelay(100, () => ent.Notify("menuresponse", "team_marinesopfor", "autoassign"));
                BaseScript.AfterDelay(300, () => ent.Notify("menuresponse", "changeclass", "class0"));

                sender.Tell($"%p{ent.Name} %nhas been spawned");
            },
                                    usage: "!spawnplayer <player>",
                                    permission: "spawnplayer",
                                    description: "Spawns the client"));

            // TEST
            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "mynotifies",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                Script.PlayerNotified.Add((sender1, args1) =>
                {
                    Entity ent = args1.Entity;

                    if (ent == sender)
                    {
                        Log.Debug("Entity: " + args1.Notify + "(" + (string.Join(", ", args1.Parameters.Select(x => x.ToString())) + ")"));
                    }
                });

                Script.Notified.Add((sender1, args1) =>
                {
                    Entity ent = null;

                    if (args1.Entity != null)
                    {
                        ent = args1.Entity;
                    }
                    else if (args1.EntityParam != null)
                    {
                        ent = args1.EntityParam;
                    }

                    if (ent != null && ent == sender)
                    {
                        Log.Debug("Level: " + args1.Notify + "(" + (string.Join(", ", args1.Parameters.Select(x => x.ToString())) + ")"));
                    }
                });
            },
                                    usage: "!mynotifies",
                                    permission: "mynotifies",
                                    description: ""));

            // TEST
            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "afkgod",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                sender.SessionTeam = "spectator";
            },
                                    usage: "!afkgod",
                                    permission: "afkgod",
                                    description: ""));

            // TEST
            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "god",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                BaseScript.OnInterval(1, () =>
                {
                    sender.Health = 1000;
                    return(true);
                });
            },
                                    usage: "!god",
                                    permission: "god",
                                    description: ""));

            // TEST
            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "test",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                BaseScript.OnInterval(100, () =>
                {
                    sender.Tell(sender.GetPlayerAngles().ToString());
                    return(true);
                });
            },
                                    usage: "!test",
                                    permission: "test",
                                    description: ""));

            Vector3 spawn;
            // SETSPAWN
            Command.TryRegister(SmartParse.CreateCommand(
                                    name : "setspawn",
                                    argTypes : null,
                                    action : delegate(Entity sender, object[] args)
            {
                spawn = sender.GetOrigin();

                Events.PlayerRespawned.Add((sender1, args1) =>
                {
                    (sender1 as Entity).SetOrigin(spawn);
                });

                Events.PlayerSpawned.Add((sender1, args1) =>
                {
                    (sender1 as Entity).SetOrigin(spawn);
                });
            },
                                    usage: "!setspawn",
                                    permission: "setspawn",
                                    description: ""));

            // SPAWNPLAYER
            Command.TryRegister(SmartParse.CreateCommand(
                                    name: "fucklamb",
                                    argTypes: new[] { SmartParse.Player, SmartParse.Boolean },
                                    action : delegate(Entity sender, object[] args)
            {
                Entity ent = args[0] as Entity;

                bool state = (bool)args[1];

                ent.SetField("EnableReverseAimbot", state);

                if (state)
                {
                    Utils.DoReverseAimbot(ent);
                }

                sender.Tell($"%p{ent.Name} %nhas been f****d");
            },
                                    usage: "!fucklamb <player> <state>",
                                    permission: "fucklamb",
                                    description: "F***s lambdur"));

            //Script.PlayerConnected.Add((sender, args) =>
            //{
            //    //if (args.Name.Contains("Lambder") || args.Name.Contains("Markus"))
            //    BaseScript.OnInterval(2000, () =>
            //    {
            //        args.SetClientDvar("cg_objectiveText", "^1Lambder");
            //        BaseScript.AfterDelay(500, () => args.SetClientDvar("cg_objectiveText", "^2Sucks"));
            //        BaseScript.AfterDelay(1000, () => args.SetClientDvar("cg_objectiveText", "^3Big"));
            //        BaseScript.AfterDelay(1500, () => args.SetClientDvar("cg_objectiveText", "^5Dicks"));

            //        return true;
            //    });
            //    //Events.WeaponChanged.Add((sender1, args1) =>
            //    //{
            //    //    Entity ent = sender1 as Entity;

            //    //    if (ent.Name.Contains("Lambder") || ent.Name.Contains("Markus"))
            //    //        Marshal.WriteInt32((IntPtr)0x01AC2488, (0x38A4 * args.EntRef), 1);
            //    //});

            //});
            #endregion

            //GSCFunctions.MakeDvarServerInfo("ui_netGametypeName", "Test");
            //GSCFunctions.MakeDvarServerInfo("party_gametype", "Test1");
            //GSCFunctions.MakeDvarServerInfo("ui_customModeName", "Test2");
            //GSCFunctions.MakeDvarServerInfo("ui_gametype", "Test3");
            //GSCFunctions.MakeDvarServerInfo("didyouknow", "Test4");
            //GSCFunctions.MakeDvarServerInfo("g_motd", "Test5");
            //GSCFunctions.MakeDvarServerInfo("ui_connectScreenTextGlowColor", "0 1 0");
        }
Exemple #19
0
        /// <summary>
        ///     Grapple onto the rooftops of moving / stationary land vehicles.
        /// </summary>
        private void VehicleGrapple(Vehicle vehicle)
        {
            if (vehicle == null)
            {
                return;
            }

            // Make sure we got a vehicle returned to us.
            if (vehicle.ClassType == VehicleClass.Helicopters || vehicle.ClassType == VehicleClass.Planes)
            {
                return;
            }

            // Disable the vehicle enter button.
            Game.DisableControlThisFrame(2, Control.Reload);

            // Check if the player has pressed the right button.
            if (Game.IsDisabledControlJustPressed(2, Control.Reload))
            {
                /////////////////////////////////////////////////////////////
                // Now we're going to launch the player towards the vehicle!
                /////////////////////////////////////////////////////////////

                // Clear the player's tasks completely, first.
                Profile.LocalUser.Task.ClearSecondary();
                Profile.LocalUser.ClearTasksImmediately();

                // A flag that let's the loop know if we've done a long distance jump.
                var twoHandedAnim = false;

                // Now we need to player our cool animations.
                if (Vector2.Distance(new Vector2(Profile.LocalUser.Position.X, Profile.LocalUser.Position.Y),
                                     new Vector2(vehicle.Position.X, vehicle.Position.Y)) > 15f)
                {
                    // Add a little RNG for the animations.
                    // For one we'll do the forward dive recover, and
                    // the other will be the backwards paddle.
                    var random   = new Random();
                    var animType = random.Next(2);

                    // The first anim (back paddle).
                    if (animType == 1)
                    {
                        Profile.LocalUser.Task.PlayAnimation("swimming@swim", "recover_back_to_idle",
                                                             4.0f, -2.0f, 1150, AnimationFlags.StayInEndFrame, 0.0f);

                        // Our two handed grapple anim.
                        Profile.LocalUser.Task.PlayAnimation("amb@world_vehicle_police_carbase", "base",
                                                             8.0f, -8.0f, 150, AnimationFlags.UpperBodyOnly | AnimationFlags.AllowRotation, 0.0f);
                        twoHandedAnim = true;
                    }
                    // Now the second anim.
                    else
                    {
                        Profile.LocalUser.Task.PlayAnimation("swimming@swim", "recover_flip_back_to_front",
                                                             4.0f, -2.0f, 1150, AnimationFlags.StayInEndFrame, 0.1f);

                        Profile.LocalUser.Task.PlayAnimation("weapons@projectile@", "throw_m_fb_stand",
                                                             8.0f, -4.0f, 100, AnimationFlags.UpperBodyOnly | AnimationFlags.AllowRotation, 0.0f);
                    }
                }
                // If it's not a long distance jump...
                else
                {
                    // Play the short distance jump animation combo.
                    Profile.LocalUser.Task.PlayAnimation("move_fall", "fall_med",
                                                         4.0f, -2.0f, 1150, AnimationFlags.StayInEndFrame, 0.0f);
                    Profile.LocalUser.Task.PlayAnimation("weapons@projectile@", "throw_m_fb_stand",
                                                         8.0f, -4.0f, 250, AnimationFlags.UpperBodyOnly | AnimationFlags.AllowRotation, 0.0f);
                }

                // Get the target direction.
                var targetDirection = vehicle.Position - Profile.LocalUser.Position;
                targetDirection.Normalize();

                // Setup our loop timer.
                var elapsedTime = 0f;

                // Create the helper obj.
                _helperObj = World.CreateVehicle("bmx", Profile.LocalUser.Position +
                                                 new Vector3(0, 100, 0));
                _helperObj.HasCollision   = false;
                _helperObj.IsVisible      = false;
                _helperObj.FreezePosition = true;
                _helperObj.Heading        = targetDirection.ToHeading();

                // The initial direction to the target used as an offset
                // for our heading.
                var initialTargetDirection = vehicle.Position - Profile.LocalUser.Position;
                initialTargetDirection.Normalize();

                // The collection of rops we will use as webs.
                var ropes = new List <Rope>();

                // The delay that we use to delete the ropes.
                var ropeDeleteDelay = 0.75f;

                // Let's do our loop.
                while (GrappleToVehicle(vehicle, twoHandedAnim,
                                        elapsedTime, initialTargetDirection, ropes, ref ropeDeleteDelay))
                {
                    Script.Yield();
                }

                // Despawn the ropes if for some reason they
                // haven't.
                DespawnRopes(ropes);

                // Delete the helper object.
                _helperObj?.Delete();

                // Now we need to clear the player's tasks.
                Profile.LocalUser.Task.ClearAll();
            }
        }
Exemple #20
0
        public void Test_AccessRuleCreate()
        {
            Definition      definition;
            long            accessRuleId;
            List <long>     entitiesToDelete;
            HttpWebResponse response;
            AccessRule      accessRule;
            UserAccount     userAccount;
            IEntity         entity;

            entitiesToDelete = new List <long>();
            try
            {
                definition = Entity.Create <Definition>();
                definition.Save();
                entitiesToDelete.Add(definition.Id);

                userAccount = Entity.Create <UserAccount>();
                userAccount.Save();
                entitiesToDelete.Add(userAccount.Id);

                using (var request = new PlatformHttpRequest("data/v1/accessrule", PlatformHttpMethod.Post))
                {
                    request.PopulateBody(new NewAccessRuleInfo
                    {
                        SubjectId         = userAccount.Id,
                        SecurableEntityId = definition.Id
                    });

                    response = request.GetResponse();
                    Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));

                    accessRuleId = request.DeserialiseResponseBody <long>();
                }

                entitiesToDelete.Add(accessRuleId);

                accessRule = Entity.Get <AccessRule>(accessRuleId);

                Assert.That(accessRule, Has.Property("AllowAccessBy").Not.Null
                            .And.Property("AllowAccessBy").Property("Id").EqualTo(userAccount.Id));
                Assert.That(accessRule, Has.Property("ControlAccess").Not.Null
                            .And.Property("ControlAccess").Property("Id").EqualTo(definition.Id));
                Assert.That(accessRule, Has.Property("AccessRuleEnabled").False);
                Assert.That(accessRule.PermissionAccess.Select(p => new EntityRef(p)),
                            Is.EquivalentTo(new [] { Permissions.Read }).Using(EntityRefComparer.Instance));

                entity = Entity.Create(definition);
                entitiesToDelete.Add(entity.Id);

                using (new SetUser(userAccount))
                {
                    Assert.That(() => Entity.Get(entity.Id), Throws.Nothing,
                                "Read access not granted to user");
                }
            }
            finally
            {
                try
                {
                    Entity.Delete(entitiesToDelete);
                }
                catch (Exception)
                {
                    // Do nothing
                }
            }
        }
        public void Test_PasswordChange()
        {
            UserAccount     userAccount;
            const string    initialPassword = "******";
            const string    newPassword     = "******";
            HttpWebResponse response;

            userAccount = null;
            try
            {
                userAccount = new UserAccount
                {
                    Name                      = "Test User " + Guid.NewGuid(),
                    Password                  = initialPassword,
                    AccountStatus_Enum        = UserAccountStatusEnum_Enumeration.Active,
                    ChangePasswordAtNextLogon = true
                };
                userAccount.Save();

                // Ensure the user can logon
                using (PlatformHttpRequest request = new PlatformHttpRequest("data/v1/login/spsignin", PlatformHttpMethod.Post, null, true))
                {
                    request.PopulateBody(new JsonLoginCredential
                    {
                        Tenant     = "EDC",
                        Username   = userAccount.Name,
                        Password   = initialPassword,
                        Persistent = false
                    });

                    response = request.GetResponse();
                    Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK),
                                "Initial logon failed");
                }

                // Change the password
                using (PlatformHttpRequest request = new PlatformHttpRequest("data/v1/password", PlatformHttpMethod.Post, userAccount))
                {
                    request.PopulateBody(new PasswordChangeInfo
                    {
                        CurrentPassword = initialPassword,
                        Password        = newPassword
                    });

                    response = request.GetResponse();
                    Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK),
                                "Password reset failed");
                }

                // Ensure the user can logon with the new password
                using (PlatformHttpRequest request = new PlatformHttpRequest("data/v1/login/spsignin", PlatformHttpMethod.Post, null, true))
                {
                    request.PopulateBody(new JsonLoginCredential
                    {
                        Tenant     = "EDC",
                        Username   = userAccount.Name,
                        Password   = newPassword,
                        Persistent = false
                    });

                    response = request.GetResponse();
                    Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK),
                                "Second logon failed");
                }

                userAccount = Entity.Get <UserAccount>(userAccount);
                Assert.That(userAccount, Has.Property("ChangePasswordAtNextLogon").False);
                Assert.That(CryptoHelper.ValidatePassword(newPassword, userAccount.Password), Is.True,
                            "Password mismatch");
            }
            finally
            {
                try
                {
                    Entity.Delete(userAccount);
                }
                catch (Exception)
                {
                    // Ignore any errors
                }
            }
        }
Exemple #22
0
        void btn_Click(object sender, EventArgs e)
        {
            string msg = "";
            Button btn = sender as Button;
            Entity en  = this.HisEns.GetNewEntity;

            if (btn.ID == "Btn_Del")
            {
                foreach (Control ctl in this.UCSys1.Controls)
                {
                    if (ctl == null || ctl.ID == null || ctl.ID == "")
                    {
                        continue;
                    }
                    if (ctl.ID.Contains("CB_") == false)
                    {
                        continue;
                    }
                    CheckBox cb = ctl as CheckBox;
                    if (cb == null)
                    {
                        continue;
                    }
                    if (cb.Checked == false)
                    {
                        continue;
                    }
                    string id = ctl.ID.Substring(3);
                    try
                    {
                        en.PKVal = id;
                        en.Delete();
                        msg += "<hr>删除成功:<font color=green>" + en.PKVal + "</font>";
                    }
                    catch (Exception ex)
                    {
                        msg += "<hr>删除错误:<font color=red>" + en.PKVal + ", 异常信息:" + ex.Message + "</font>";
                    }
                }
            }
            else
            {
                int idx = int.Parse(btn.ID.Replace("Btn_", ""));
                foreach (Control ctl in this.UCSys1.Controls)
                {
                    if (ctl == null || ctl.ID == null || ctl.ID == "")
                    {
                        continue;
                    }
                    if (ctl.ID.Contains("CB_") == false)
                    {
                        continue;
                    }

                    CheckBox cb = ctl as CheckBox;
                    if (cb == null)
                    {
                        continue;
                    }
                    if (cb.Checked == false)
                    {
                        continue;
                    }

                    string id = ctl.ID.Substring(3);
                    try
                    {
                        en.PKVal = id;
                        en.Retrieve();
                        BP.En.RefMethod rm = en.EnMap.HisRefMethods[idx];
                        rm.HisEn = en;
                        msg     += "<hr>执行:" + en.PKVal + " 信息:<br>" + rm.Do(null);
                    }
                    catch (Exception ex)
                    {
                        msg += "<hr>执行错误:<font color=red>主键值:" + en.PKVal + "<br>" + ex.Message + "</font>";
                    }
                }
            }
            if (msg == "")
            {
                msg = "您没有选择行...";
            }

            this.Session["Info"] = msg;
            this.Response.Redirect("Batch.aspx?EnsName=" + this.EnsName, true);
            // this.Response.Redirect(this.Request.RawUrl, true);
        }
        /// <summary>
        /// Builds the crystal at a specified position and a color.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="args">[0] = position; [1] = color; [2] amount</param>
        /// <returns></returns>
        public Entity BuildEntity(Entity e, params object[] args)
        {
            Vector2 pos = (Vector2)args[0];
            Color color = (Color)args[1];
            string source = "redcrystal";

            e.AddComponent<Components.Timer>(new Components.Timer(10));

            if (color == Color.Red)
                source = "redcrystal";
            if (color == Color.Blue)
                source = "bluecrystal";
            if (color == Color.Yellow)
                source = "yellowcrystal";
            if (color == Color.Green)
                source = "greencrystal";
            if (color == Color.Gray)
                source = "graycrystal";

            Sprite s = e.AddComponent<Sprite>(new Sprite(_SpriteSheet, source, 0.2f + (float)crystals / 10000f));
            Body b = e.AddComponent<Body>(new Body(_World, e));
            b.IsBullet = true;
            FixtureFactory.AttachEllipse((float)ConvertUnits.ToSimUnits(s.CurrentRectangle.Width / 1.5), (float)ConvertUnits.ToSimUnits(s.CurrentRectangle.Height / 1.5), 3, 1f, b);

            b.Position = pos;
            b.BodyType = GameLibrary.Dependencies.Physics.Dynamics.BodyType.Dynamic;

            e.GetComponent<Body>().OnCollision += LambdaComplex.CrystalCollision();

            if (args.Length > 4)
            {
                e.AddComponent<Crystal>(new Crystal(color, (int)args[2], true));
                e.AddComponent<AI>(new AI((args[3] as Entity).GetComponent<Body>(), AI.CreateFollow(e, 5f, false)));
            }
            else if (args.Length > 3)
            {
                e.AddComponent<Crystal>(new Crystal(color, (int)args[2]));
                e.AddComponent<AI>(new AI((args[3] as Entity).GetComponent<Body>(), AI.CreateFollow(e, 5f, false)));
            }

            else
            {
                e.AddComponent<Crystal>(new Crystal(color, (int)args[2]));
            }
            e.Group = "Crystals";

            e.AddComponent<AI>(new AI((args[3] as Entity).GetComponent<Body>(), //AI was severely lagging the game.
                (target) =>
                {
                    if ((target.UserData as Entity).HasComponent<Health>() && (target.UserData as Entity).GetComponent<Health>().IsAlive && target.Position != b.Position && (target.UserData as Entity).Group == "Players")
                    {
                        Vector2 distance = target.Position - b.Position;
                        distance.Normalize();
                        b.LinearVelocity = distance * new Vector2(14);
                        return false;
                    }
                    else
                    {
                        e.Delete();
                        return false;
                    }
                }));

            e.Refresh();
            return e;
        }
Exemple #24
0
 public virtual void EntityDidHit(Entity entity)
 {
     Entity.Delete();
 }
Exemple #25
0
        /// <summary>
        /// 删除功能
        /// </summary>
        /// <param name="strIds">ids</param>
        /// <param name="iDeptID">iDeptID</param>
        /// <param name="bActual">物理删除还是逻辑删除</param>
        /// <returns></returns>
        public static bool Delete(string strIds, int iDeptID, bool bActual)
        {
            string strSql = string.Format("[ID] IN ({0})", strIds);

            return(Entity.Delete(DeptPost.TableName, strSql, bActual) > 0);
        }
Exemple #26
0
        public static void DeleteAllBombSites()
        {
            // @author: Slvr99
            if (GSCFunctions.GetDvar("g_gametype") != "sd")
            {
                return;
            }

            Entity bomb  = GetBombs("bombzone");
            Entity bomb1 = GetBombTarget(GetBombTarget(bomb));//Trigger

            if (bomb1 != null)
            {
                bomb1.Delete();
            }
            bomb1 = GetBombTarget(GetBombs("bombzone"));//model
            if (bomb1 != null)
            {
                bomb1.Delete();
            }
            bomb1 = GetBombs("bombzone");//plant trigger
            if (bomb1 != null)
            {
                bomb1.Delete();
            }

            Entity bomb2 = GetBombTarget(GetBombTarget(GetBombs("bombzone")));//Trigger

            if (bomb2 != null)
            {
                bomb2.Delete();
            }
            bomb2 = GetBombTarget(GetBombs("bombzone"));//model
            if (bomb2 != null)
            {
                bomb2.Delete();
            }
            bomb2 = GetBombs("bombzone");//plant trigger
            if (bomb2 != null)
            {
                bomb2.Delete();
            }

            DeleteBombCol();                          //Collision
            DeleteBombCol();                          //Collision

            GetBombs("sd_bomb_pickup_trig").Delete(); //Bomb pickup trigger
            GetBombs("sd_bomb").Delete();             //bomb pickup model

            HudElem bombIcon       = HudElem.GetHudElem(65536);
            HudElem bombIcon_enemy = HudElem.GetHudElem(65537);//Unknown?
            HudElem aSite_planting = HudElem.GetHudElem(65538);
            HudElem aSite_defusing = HudElem.GetHudElem(65539);
            HudElem bSite_planting = HudElem.GetHudElem(65540);
            HudElem bSite_defusing = HudElem.GetHudElem(65541);

            bombIcon.Destroy();
            bombIcon_enemy.Destroy();
            aSite_defusing.Destroy();
            aSite_planting.Destroy();
            bSite_planting.Destroy();
            bSite_defusing.Destroy();
        }
 public override void Process(Entity entity)
 {
     entity.Delete();
 }
        /// <summary>Processes the specified entity.</summary>
        /// <param name="entity">The entity.</param>
        public override void Process(Entity entity)
        {
            ExpiresComponent expiresComponent = this.expiresMapper.Get(entity);
            if (expiresComponent != null)
            {
                float ms = TimeSpan.FromTicks(this.EntityWorld.Delta).Milliseconds;
                expiresComponent.ReduceLifeTime(ms);

                if (expiresComponent.IsExpired)
                {
                    entity.Delete();
                }
            }
        }
        public override void Process(Entity e)
        {
            AI ai = e.GetComponent<AI>();

            switch (ai.Targeting)
            {
                case Targeting.Closest:
                    ai.Target = ClosestTarget(e);
                    break;

                case Targeting.Strongest:
                    ai.Target = StrongestEntity(world.GetBodiesInArea(e.GetComponent<ITransform>().Position, ai.SearchRadius)).GetComponent<Body>();
                    break;

                case Targeting.Weakest:
                    ai.Target = WeakestEntity(world.GetBodiesInArea(e.GetComponent<ITransform>().Position, ai.SearchRadius)).GetComponent<Body>();
                    break;
            }

            if (e.Group == "Crystals")
            {
                if ((ai.Target.UserData as Entity).DeletingState != true)
                {
                    Vector2 distance = e.GetComponent<AI>().Target.Position - e.GetComponent<Body>().Position;
                    distance.Normalize();
                    e.GetComponent<Body>().LinearVelocity = distance * new Vector2(7);
                }
                else
                {
                    e.Delete();

                    //ai.Target = ClosestTarget(e);
                }
            }
            e.RemoveComponent<AI>(e.GetComponent<AI>());
            e.AddComponent<AI>(ai);
        }