Example #1
0
        private void Teleport(Vector3 Location, float Rotation, IRocketPlayer caller, string name = null)
        {
            int           numPlayers = Provider.clients.Count;
            List <string> excluded   = new List <string>();

            if (numPlayers == 0)
            {
                UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("no_players_tpall"));
                return;
            }
            if (name == null)
            {
                name = Location.xyz_Location();
            }
            foreach (SteamPlayer player in Provider.clients)
            {
                // Don't teleport the player to teleport if they are in a car.
                if (player.player.stance.stance == EPlayerStance.DRIVING || player.player.stance.stance == EPlayerStance.SITTING)
                {
                    numPlayers--;
                    excluded.Add(player.playerID.characterName);
                    continue;
                }
                UnturnedChat.Say(player.playerID.steamID, TeleportUtil.Instance.Translate("tp_success", name));
                player.player.sendTeleport(Location, MeasurementTool.angleToByte(Rotation));
            }
            UnturnedChat.Say(caller, TeleportUtil.Instance.Translate("tpall_num_teleported", numPlayers, name, string.Join(", ", excluded.ToArray())));
        }
        private void OnTransformStructureRequested(CSteamID instigator, byte x, byte y, uint instanceId,
                                                   ref Vector3 point, ref byte angleX, ref byte angleY, ref byte angleZ, ref bool shouldAllow)
        {
            if (!StructureManager.tryGetRegion(x, y, out var region))
            {
                return;
            }

            var index = region.structures.FindIndex(k => k.instanceID == instanceId);
            var data  = region.structures[index];
            var drop  = region.drops[index];

            var nativePlayer = Provider.clients.FirstOrDefault(cl => cl?.playerID.steamID == instigator)?.player;
            var player       = nativePlayer == null ? null : new UnturnedPlayer(nativePlayer);

            var @event = new UnturnedStructureTransformingEvent(
                new UnturnedStructureBuildable(data, drop), player, instigator, point,
                Quaternion.Euler(angleX * 2, angleY * 2, angleZ * 2));

            Emit(@event);

            shouldAllow = [email protected];
            point       = @event.Point;

            var eulerAngles = @event.Rotation.eulerAngles;

            angleX = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.x / 2f) * 2);
            angleY = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.y / 2f) * 2);
            angleZ = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.z / 2f) * 2);
        }
Example #3
0
        private void OnTransformStructureRequested(CSteamID instigator, byte x, byte y, uint instanceId, // lgtm [cs/too-many-ref-parameters]
                                                   ref Vector3 point, ref byte angleX, ref byte angleY, ref byte angleZ, ref bool shouldAllow)
        {
            if (!StructureManager.tryGetRegion(x, y, out var region))
            {
                return;
            }

            var index = region.structures.FindIndex(k => k.instanceID == instanceId);
            var data  = region.structures[index];
            var drop  = region.drops[index];

            var nativePlayer = PlayerTool.getPlayer(instigator);
            var player       = GetUnturnedPlayer(nativePlayer);

            var rot = Quaternion.Euler(angleX * 2, angleY * 2, angleZ * 2); // lgtm [cs/loss-of-precision]

            var @event = new UnturnedStructureTransformingEvent(
                new UnturnedStructureBuildable(data, drop), player !, instigator, point, rot)
            {
                IsCancelled = !shouldAllow
            };

            Emit(@event);

            shouldAllow = [email protected];
            point       = @event.Point;

            var eulerAngles = @event.Rotation.eulerAngles;

            angleX = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.x / 2f) * 2); // lgtm [cs/loss-of-precision]
            angleY = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.y / 2f) * 2); // lgtm [cs/loss-of-precision]
            angleZ = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.z / 2f) * 2); // lgtm [cs/loss-of-precision]
        }
Example #4
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;
            Vector3        pos;
            byte           rot;

            if (!BarricadeManager.tryGetBed(player.CSteamID, out pos, out rot))
            {
                UnturnedChat.Say(caller, U.Translate("command_bed_no_bed_found_private"));
                throw new WrongUsageOfCommandException(caller, this);
            }
            else
            {
                if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING)
                {
                    UnturnedChat.Say(caller, U.Translate("command_generic_teleport_while_driving_error"));
                    throw new WrongUsageOfCommandException(caller, this);
                }
                else
                {
                    pos.y += 0.5f; // Respawn uses this offset.
                    float yaw = MeasurementTool.byteToAngle(rot);
                    bool  teleportSuccessful = player.Player.teleportToLocation(pos, yaw);
                    if (!teleportSuccessful)
                    {
                        UnturnedChat.Say(caller, U.Translate("command_bed_obstructed"));
                    }
                }
            }
        }
Example #5
0
        public Task <bool> SetPositionAsync(Vector3 position, Vector3 rotation)
        {
            async UniTask <bool> TeleportationTask()
            {
                await UniTask.SwitchToMainThread();

                if (Player.transform.position == position.ToUnityVector() &&
                    Player.transform.rotation.eulerAngles == rotation.ToUnityVector())
                {
                    return(true);
                }

                if (!ValidationHelper.IsValid(position) || !ValidationHelper.IsValid(rotation))
                {
                    return(false);
                }

                var rotationAngle = MeasurementTool.angleToByte(rotation.Y);

                Player.channel.send("askTeleport", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, position, rotationAngle);
                return(true);
            }

            return(TeleportationTask().AsTask());
        }
Example #6
0
        public void Teleport(UnturnedPlayer target)
        {
            Vector3 d1       = target.player.transform.position;
            Vector3 vector31 = target.player.transform.rotation.eulerAngles;

            player.sendTeleport(d1, MeasurementTool.angleToByte(vector31.y));
        }
Example #7
0
        private void OnTransformStructureRequested(CSteamID instigator, byte x, byte y, uint instanceID,
                                                   ref Vector3 point, ref byte angle_x, ref byte angle_y, ref byte angle_z, ref bool shouldAllow)
        {
            StructureRegion region = StructureManager.regions[x, y];
            int             index  = region.structures.FindIndex(k => k.instanceID == instanceID);

            StructureData data = region.structures[index];
            StructureDrop drop = region.drops[index];

            Player nativePlayer = Provider.clients.FirstOrDefault(x => x?.playerID.steamID == instigator)?.player;

            UnturnedPlayer player = nativePlayer == null ? null : new UnturnedPlayer(nativePlayer);

            UnturnedStructureTransformingEvent @event = new UnturnedStructureTransformingEvent(
                new UnturnedStructureBuildable(data, drop), player, instigator, point,
                Quaternion.Euler(angle_x * 2, angle_y * 2, angle_z * 2));

            Emit(@event);

            shouldAllow = [email protected];
            point       = @event.Point;

            Vector3 eulerAngles = @event.Rotation.eulerAngles;

            angle_x = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.x / 2f) * 2);
            angle_y = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.y / 2f) * 2);
            angle_z = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.z / 2f) * 2);
        }
Example #8
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length != 1 && command.Length != 3)
            {
                UnturnedChat.Say(player, U.Translate("command_generic_invalid_parameter"));
                return;
            }

            if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING)
            {
                UnturnedChat.Say(player, U.Translate("command_generic_teleport_while_driving_error"));
                return;
            }

            float?x = null;
            float?y = null;
            float?z = null;

            if (command.Length == 3)
            {
                x = command.GetFloatParameter(0);
                y = command.GetFloatParameter(1);
                z = command.GetFloatParameter(2);
            }
            if (x != null && y != null && z != null)
            {
                player.Teleport(new Vector3((float)x, (float)y, (float)z), MeasurementTool.angleToByte(player.Rotation));
                Logger.Log(U.Translate("command_tp_teleport_console", player.CharacterName, (float)x + "," + (float)y + "," + (float)z));
                UnturnedChat.Say(player, U.Translate("command_tp_teleport_private", (float)x + "," + (float)y + "," + (float)z));
            }
            else
            {
                UnturnedPlayer otherplayer = UnturnedPlayer.FromName(command[0]);
                if (otherplayer != null && otherplayer != player)
                {
                    player.Teleport(otherplayer);
                    Logger.Log(U.Translate("command_tp_teleport_console", player.CharacterName, otherplayer.CharacterName));
                    UnturnedChat.Say(player, U.Translate("command_tp_teleport_private", otherplayer.CharacterName));
                }
                else
                {
                    Node item = LevelNodes.Nodes.Where(n => n.NodeType == ENodeType.LOCATION && ((LocationNode)n).Name.ToLower().Contains(command[0].ToLower())).FirstOrDefault();
                    if (item != null)
                    {
                        Vector3 c = item.Position + new Vector3(0f, 0.5f, 0f);
                        player.Teleport(c, MeasurementTool.angleToByte(player.Rotation));
                        Logger.Log(U.Translate("command_tp_teleport_console", player.CharacterName, ((LocationNode)item).Name));
                        UnturnedChat.Say(player, U.Translate("command_tp_teleport_private", ((LocationNode)item).Name));
                    }
                    else
                    {
                        UnturnedChat.Say(player, U.Translate("command_tp_failed_find_destination"));
                    }
                }
            }
        }
        public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;

            if (command.Length == 2 || command.Length > 3)
            {
                UnturnedChat.Say(player, U.Translate("command_generic_invalid_parameter"));
                throw new WrongUsageOfCommandException(caller, this);
            }

            if (player.Stance == EPlayerStance.DRIVING || player.Stance == EPlayerStance.SITTING)
            {
                UnturnedChat.Say(player, U.Translate("command_generic_teleport_while_driving_error"));
                throw new WrongUsageOfCommandException(caller, this);
            }

            if (command.Length == 0 && player.HasPermission("rocket.i.forward"))
            {
                Physics.Raycast(player.Player.look.aim.position, player.Player.look.aim.forward, out RaycastHit raycast);
                player.Teleport(new Vector3(raycast.point.x, raycast.point.y + 3f, raycast.point.z), player.Rotation);
                UnturnedChat.Say(caller, U.Translate("command_tp_teleport", "You", "forward."));
                Core.Logging.Logger.Log(U.Translate("command_tp_teleport", player.CharacterName, "forward"));
            }

            if (command.Length == 3 && float.TryParse(command[0], out float x) && float.TryParse(command[1], out float y) && float.TryParse(command[2], out float z))
            {
                player.Teleport(new Vector3(x, y, z), MeasurementTool.angleToByte(player.Rotation));
                Core.Logging.Logger.Log(U.Translate("command_tp_teleport", player.CharacterName, x + "," + y + "," + z));
                UnturnedChat.Say(player, U.Translate("command_tp_teleport", x + "," + y + "," + z));
            }
            else
            {
                if (command.Length == 0)
                {
                    return;
                }
                UnturnedPlayer otherplayer = UnturnedPlayer.FromName(command[0]);
                if (otherplayer != null && otherplayer != player)
                {
                    player.Teleport(otherplayer);
                    Core.Logging.Logger.Log(U.Translate("command_tp_teleport", player.CharacterName, otherplayer.CharacterName));
                    UnturnedChat.Say(player, U.Translate("command_tp_teleport", "You", otherplayer.CharacterName));
                }
                else
                {
                    Node item = LevelNodes.nodes.Where(n => n.type == ENodeType.LOCATION && ((LocationNode)n).name.ToLower().Contains(command[0].ToLower())).FirstOrDefault();
                    if (item == null)
                    {
                        UnturnedChat.Say(player, U.Translate("command_tp_failed_find_destination"));
                        return;
                    }
                    Vector3 c = item.point + new Vector3(0f, 0.5f, 0f);
                    player.Teleport(c, MeasurementTool.angleToByte(player.Rotation));
                    Core.Logging.Logger.Log(U.Translate("command_tp_teleport", player.CharacterName, ((LocationNode)item).name));
                    UnturnedChat.Say(player, U.Translate("command_tp_teleport", "You", ((LocationNode)item).name));
                }
            }
        }
Example #10
0
        public bool Teleport(string nodeName)
        {
            Node node = LevelNodes.Nodes.Where(n => n.NodeType == ENodeType.LOCATION && ((LocationNode)n).Name.ToLower().Contains(nodeName)).FirstOrDefault();

            if (node != null)
            {
                Vector3 c = node.Position + new Vector3(0f, 0.5f, 0f);
                player.sendTeleport(c, MeasurementTool.angleToByte(Rotation));
                return(true);
            }
            return(false);
        }
 public void FixedUpdate()
 {
     gameObject.transform.position += Velocity * Time.deltaTime;
     if (Player != null)
     {
         Player.sendTeleport(gameObject.transform.position, MeasurementTool.angleToByte(gameObject.transform.eulerAngles.y));
     }
     Velocity -= Deceleration;
     if (Velocity.sqrMagnitude < 1)
     {
         Destroy(this);
     }
 }
Example #12
0
        public override CommandResult OnExecute(ICommandSource src, ICommandArgs args)
        {
            var player   = src.ToPlayer();
            var playerId = player.CSteamId;

            if (player.Stance == EPlayerStance.DRIVING ||
                player.Stance == EPlayerStance.SITTING)
            {
                return(CommandResult.LangError("CANNOT_TELEPORT_DRIVING"));
            }

            if (!BarricadeManager.tryGetBed(player.CSteamId, out var bedPosition, out var bedAngle))
            {
                return(CommandResult.LangError("WITHOUT_BED"));
            }

            if (Delay.ContainsKey(player.CSteamId.m_SteamID))
            {
                return(CommandResult.LangError("ALREADY_WAITING"));
            }

            var homeCommand = UEssentials.Config.Home;
            var delay       = homeCommand.TeleportDelay;

            if (player.HasPermission("essentials.bypass.homecooldown"))
            {
                delay = 0;
            }

            if (delay > 0)
            {
                EssLang.Send(src, "TELEPORT_DELAY", TimeUtil.FormatSeconds((uint)delay));
            }

            var task = Task.Create()
                       .Delay(TimeSpan.FromSeconds(delay))
                       .Action(t => {
                Delay.Remove(playerId.m_SteamID);
                bedPosition.y += .5f;
                player.UnturnedPlayer.teleportToLocation(bedPosition, MeasurementTool.byteToAngle(bedAngle));
                EssLang.Send(src, "TELEPORTED_BED");
            })
                       .Submit();

            Delay.Add(playerId.m_SteamID, task);

            return(CommandResult.Success());
        }
        internal static void InternalOnRevived(PlayerLife sender)
        {
            UnturnedPlayerEvents instance = sender.GetComponent <UnturnedPlayerEvents>();
            UnturnedPlayer       rp       = UnturnedPlayer.FromPlayer(sender.player);

            // First parameter of tellLife was health.
            OnPlayerUpdateLife.TryInvoke(rp, sender.health);
            instance.OnUpdateLife.TryInvoke(rp, sender.health);

            // Ideally avoid using this angleToByte method in new code. Please.
            Vector3 position = sender.transform.position;
            byte    angle    = MeasurementTool.angleToByte(sender.transform.rotation.eulerAngles.y);

            OnPlayerRevive.TryInvoke(rp, position, angle);
            instance.OnRevive.TryInvoke(rp, position, angle);
        }
        public void Teleport(Vector3 position, float rotation)
        {
            var b = MeasurementTool.angleToByte(rotation);

            player.askTeleport(Provider.server, position, b);
            player.channel.send("askTeleport", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_INSTANT, position, b);

            /*player.movement.channel.send("tellRecov", ESteamCall.OWNER, ESteamPacket.UPDATE_UNRELIABLE_INSTANT, new object[]
             * {
             *  position,
             *  player.input.recov
             * });*/
            if (!VanishMode)
            {
                player.channel.send("askTeleport", ESteamCall.NOT_OWNER, ESteamPacket.UPDATE_RELIABLE_INSTANT, position, b);
            }
        }
        public static void dropStructure(Structure structure, Vector3 point, float angle_x, float angle_y, float angle_z, ulong owner, ulong group)
        {
            ItemStructureAsset itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, structure.id);

            if (itemStructureAsset == null)
            {
                return;
            }
            Vector3 eulerAngles = Quaternion.Euler(-90f, angle_y, 0f).eulerAngles;

            angle_x = (float)(Mathf.RoundToInt(eulerAngles.x / 2f) * 2);
            angle_y = (float)(Mathf.RoundToInt(eulerAngles.y / 2f) * 2);
            angle_z = (float)(Mathf.RoundToInt(eulerAngles.z / 2f) * 2);
            byte            b;
            byte            b2;
            StructureRegion structureRegion;
            bool            cancel = false;

            if (!Regions.tryGetCoordinate(point, out b, out b2) ||
                !StructureManager.tryGetRegion(b, b2, out structureRegion))
            {
                return;
            }
            StructureData structureData = new StructureData(structure, point, MeasurementTool.angleToByte(angle_x), MeasurementTool.angleToByte(angle_y), MeasurementTool.angleToByte(angle_z), owner, @group, Provider.time);

            ServerEvents.RunStructureCreated(structureData, ref cancel);
            if (cancel)
            {
                return;
            }
            structureRegion.structures.Add(structureData);
            StructureManager.instance.channel.send("tellStructure", ESteamCall.ALL, b, b2, StructureManager.STRUCTURE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
            {
                b,
                b2,
                structure.id,
                structureData.point,
                structureData.angle_x,
                structureData.angle_y,
                structureData.angle_z,
                owner,
                @group,
                (uint)typeof(StructureManager).GetField("instanceCount", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)
            });
        }
Example #16
0
 public void Teleport(Vector3 position, float rotation)
 {
     player.sendTeleport(position, MeasurementTool.angleToByte(rotation));
 }
        public void Create(ref MeasurementTool tool, List <MasterItem> items = null, List <MasterCustomer> customers = null)
        {
            int  workloadSize = 10_00;
            long maxVal       = Customers.OrderByDescending(cus => cus.ID).First().ID;

            MasterCustomer[] cusArray  = MasterCustomer.GenerateCustomers(500, "createDeNorm", maxVal).ToArray();
            MasterItem[]     itemArray = items.ToArray();

            Random   new_or_oldSelector   = new Random(4573);
            Random   customerGenSelector  = new Random(867542);
            Random   customerSelector     = new Random(456542);
            Random   satisfySelector      = new Random(2678);
            Random   storeSelector        = new Random(236786);
            Random   diffItemSelector     = new Random(83457);
            Random   quantityItemSelector = new Random(6526);
            Random   itemSelector         = new Random(572);
            Random   dateSelector         = new Random(6762);
            DateTime startDate            = new DateTime(2020, 1, 2);
            DateTime endDate = new DateTime(2020, 5, 28);
            int      range   = (endDate - startDate).Days;

            for (int i = 0; i < workloadSize; i++)
            {
                Console.WriteLine($"{i} ud af {workloadSize}");
                int      new_old  = new_or_oldSelector.Next(0, 2);
                string   title    = new_old == 0 ? "PostgreSQL,Sale,DeNorm,Create,New user" : "PostgreSQL,Sale,DeNorm,Create,Existing user";
                Customer customer = null;
                //New
                if (new_old == 0)
                {
                    MasterCustomer tmpcustomer = cusArray[customerGenSelector.Next(0, cusArray.Length)];
                    customer = new Customer
                    {
                        Age    = tmpcustomer.Age,
                        Email  = tmpcustomer.Email,
                        Gender = tmpcustomer.Gender,
                    };
                    tool.Stopwatch.Start();
                    Customers.Add(customer);
                    Console.WriteLine(customer.ID);
                    SaveChanges();
                    tool.Stopwatch.Stop();
                }
                //Exisiting
                else
                {
                    int  max    = (int)Customers.OrderByDescending(cus => cus.ID).First().ID;
                    long ranpos = (long)customerSelector.Next(1, max);
                    customer = Customers.Find(ranpos);
                }
                int satisfactorynumber = satisfySelector.Next(0, 10);
                //Item selection and Saleitem creation
                List <string> usedItems = new List <string>();
                int           diffItems = diffItemSelector.Next(1, 5);
                long?         tmpSaleId = null;
                for (int j = 0; j < diffItems; j++)
                {
                    int itemIndex = itemSelector.Next(0, itemArray.Length);
                    if (!usedItems.Contains(itemArray[itemIndex].Name))
                    {
                        // Find item
                        usedItems.Add(itemArray[itemIndex].Name);
                        int  itemQuant = quantityItemSelector.Next(1, 5);
                        Item foundItem = Items.Where(it => it.Name.Equals(itemArray[itemIndex].Name)).First();
                        //Sale creation
                        Sale sale = new Sale
                        {
                            ID                         = tmpSaleId,
                            ItemId                     = foundItem.ID,
                            ItemName                   = foundItem.Name,
                            ItemPrice                  = foundItem.Price,
                            ItemQuantity               = itemQuant,
                            CustomerId                 = customer.ID,
                            CustomerAge                = customer.Age,
                            CustomerEmail              = customer.Email,
                            CustomerGender             = customer.Gender,
                            Date                       = startDate.AddDays(dateSelector.Next(range)),
                            CouponUsed                 = false,
                            PurchaseMethod             = "Card",
                            StoreLocation              = StoreLocation.Locations[storeSelector.Next(0, 9)],
                            CustomerSatisfactoryNumber = satisfactorynumber
                        };
                        tool.Stopwatch.Start();
                        Sales.Add(sale);
                        SaveChanges();
                        tool.Stopwatch.Stop();
                        tmpSaleId = sale.ID;
                    }
                    else
                    {
                        break;
                    }
                }
                //Saves measurements every sale update
                tool.SaveAndReset(title);
            }
        }
        public void Seed(int dbSize, List <MasterItem> items, List <MasterCustomer> customers, List <string> tags = null)
        {
            Dictionary <string, long>   tagger             = new Dictionary <string, long>();
            Dictionary <long, Customer> customerdictionary = new Dictionary <long, Customer>();
            Dictionary <long, Item>     itemdictionary     = new Dictionary <long, Item>();

            Console.WriteLine("Adding customers");
            //Then insert customers into the db
            foreach (MasterCustomer customer in customers)
            {
                Customer tmpCus = new Customer {
                    ID = customer.Id, Age = customer.Age, Email = customer.Email, Gender = customer.Gender
                };
                Customers.Add(tmpCus);
                SaveChanges();
                customerdictionary.Add(tmpCus.ID, tmpCus);
            }
            //Dbsize should correspond to the amount of sales already exisitng in the db, which it should be seeded with.
            //Therefore we need to generate customers, and items.
            Console.WriteLine("Adding tags");
            foreach (var tag in tags)
            {
                Tag newtag = new Tag {
                    Name = tag
                };
                Tags.Add(newtag);
                SaveChanges();
                tagger.Add(newtag.Name, newtag.ID);
            }
            Console.WriteLine("Adding items");
            //First insert items into the db
            foreach (MasterItem item in items)
            {
                Item dbItem = new Item
                {
                    ID    = item.Id,
                    Name  = item.Name,
                    Price = item.Price
                };
                itemdictionary.Add(item.Id, dbItem);
                Items.Add(dbItem);
                long tmp = -1;
                tagger.TryGetValue(item.Tag1, out tmp);
                ItemTags.Add(new TagItems {
                    ItemId = item.Id, TagId = tmp
                });
                if (item.Tag2 != null)
                {
                    tagger.TryGetValue(item.Tag2, out tmp);
                    ItemTags.Add(new TagItems {
                        ItemId = item.Id, TagId = tmp
                    });
                }
                if (item.Tag3 != null)
                {
                    tagger.TryGetValue(item.Tag3, out tmp);
                    ItemTags.Add(new TagItems {
                        ItemId = item.Id, TagId = tmp
                    });
                }
            }


            Console.WriteLine("Gen seed");
            //Then generate seeded sales
            Random          customerSelecter     = new Random(123456);
            Random          itemAmountSelector   = new Random(12341);
            Random          itemTypeSelector     = new Random(634784);
            Random          itemSelecter         = new Random(6463526);
            Random          dateSelecotr         = new Random(3435468);
            Random          satisfactionSelecotr = new Random(39843);
            Random          StoreSelecotr        = new Random(74626);
            DateTime        startDate            = new DateTime(2015, 1, 1);
            DateTime        endDate = new DateTime(2020, 1, 1);
            int             range   = (endDate - startDate).Days;
            MeasurementTool tool    = new MeasurementTool(0, 0, 0, "");

            for (int i = 1; i <= dbSize; i++)
            {
                List <Sale> sameSale = new List <Sale>();
                //Define Once
                long     tmpcid   = (long)customerSelecter.Next(1, customers.Count);
                Customer customer = null;
                customerdictionary.TryGetValue(tmpcid, out customer);

                //Define items to buy
                int         itemsToBuy = itemTypeSelector.Next(1, 5);
                long?       tmpSaleId  = null;
                List <long> idUsed     = new List <long>();
                for (int j = 0; j < itemsToBuy; j++)
                {
                    long tmpiid = (long)itemSelecter.Next(1, items.Count);
                    if (!idUsed.Contains(tmpiid))
                    {
                        idUsed.Add(tmpiid);
                        itemdictionary.TryGetValue(tmpiid, out Item itemtobuy);
                        var tmpSale = new Sale
                        {
                            //ID = tmpSaleId,
                            Date                       = startDate.AddDays(dateSelecotr.Next(range)),
                            ItemId                     = itemtobuy.ID,
                            ItemName                   = itemtobuy.Name,
                            ItemPrice                  = itemtobuy.Price,
                            ItemQuantity               = itemAmountSelector.Next(1, 5),
                            CustomerId                 = customer.ID,
                            CustomerAge                = customer.Age,
                            CustomerEmail              = customer.Email,
                            CustomerGender             = customer.Gender,
                            CustomerSatisfactoryNumber = satisfactionSelecotr.Next(0, 10),
                            CouponUsed                 = false,
                            PurchaseMethod             = "Card",
                            StoreLocation              = StoreLocation.Locations[StoreSelecotr.Next(0, 9)]
                        };
                        Sales.Add(tmpSale);


                        Console.WriteLine(tmpSale.ID);
                        tmpSaleId = tmpSale.ID;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            //Then insert seeded sales into the db
            SaveChanges();
        }
Example #19
0
 public void Teleport(Vector3 position, float rotation)
 {
     if (VanishMode)
     {
         player.channel.send("askTeleport", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, position, MeasurementTool.angleToByte(rotation));
         player.channel.send("askTeleport", ESteamCall.NOT_OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new Vector3(position.y, position.y + 1337, position.z), MeasurementTool.angleToByte(rotation));
         player.channel.send("askTeleport", ESteamCall.SERVER, ESteamPacket.UPDATE_RELIABLE_BUFFER, position, MeasurementTool.angleToByte(rotation));
     }
     else
     {
         player.channel.send("askTeleport", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, position, MeasurementTool.angleToByte(rotation));
     }
 }
Example #20
0
        /// <summary>
        /// Teleports the user's character to the specified position
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="z"></param>
        public void Teleport(float x, float y, float z)
        {
            var vector31 = steamPlayer.player.transform.rotation.eulerAngles;

            steamPlayer.player.sendTeleport(new Vector3(x, y, z), MeasurementTool.angleToByte(vector31.y));
        }
Example #21
0
 public void Create(ref MeasurementTool tool, List <MasterItem> items = null, List <MasterCustomer> customers = null)
 {
     throw new NotImplementedException();
 }
Example #22
0
 public void Updater(ref MeasurementTool tool)
 {
     throw new NotImplementedException();
 }
Example #23
0
        public static void OV_FixedUpdate(PlayerInput instance)
        {
            if (instance.player != OptimizationVariables.MainPlayer)
            {
                return;
            }

            Player player = OptimizationVariables.MainPlayer;

            if (Step == -1)
            {
                Rate = 4;
                Run  = false;
            }

            else if (Step == 1 && !Run)
            {
                Run = true;
            }

            else if (Step == 2)
            {
                /*
                 * Buffer++;
                 * if (Buffer > 3)
                 *      Buffer = 0;
                 *
                 * if (MiscOptions.TimeAcceleration == 1 && Buffer % 4 != 0)
                 *      return;
                 *
                 * if (MiscOptions.TimeAcceleration == 2 && Buffer % 2 != 0)
                 *      return;
                 */

                Run = false;

                switch (MiscOptions.TimeAcceleration)
                {
                case 1:
                    Rate = 4;
                    break;

                case 2:
                    Rate = 2;
                    break;

                case 4:
                    Rate = 1;
                    break;
                }
            }

            if (!Run && SequenceDiff <= 0)
            {
                Rate         = 4;
                SequenceDiff = 0;
                Step         = -1;

                Run = false;
            }

            Count++;

            if (Count % Rate == 0u)
            {
                if (Rate == 1)
                {
                    SequenceDiff--;
                }

                else if (Rate == 2 && Count % 4 == 0)
                {
                    SequenceDiff--;
                }

                if (Run)
                {
                    if (Time.realtimeSinceStartup - LastReal > 8)
                    {
                        LastReal = Time.realtimeSinceStartup;
                    }

                    else
                    {
                        SequenceDiff++;
                        return;
                    }
                }

                SetTick(instance, Time.realtimeSinceStartup);

                instance.keys[0] = player.movement.jump;
                instance.keys[1] = player.equipment.primary;

                // Phase between false and true every other tick to simulate rapid tapping of the mouse
                // (gunfire is simulated server-side from inputs)
                if (WeaponOptions.FastSemiAuto &&
                    player.equipment.useable is UseableGun gun &&
                    (GetFiremode(gun) == EFiremode.SEMI || GetFiremode(gun) == EFiremode.BURST) &&
                    player.equipment.primary)
                {
                    if (!clicking)
                    {
                        instance.keys[1] = true;
                        clicking         = true;
                    }
                    else
                    {
                        instance.keys[1] = false;
                        clicking         = false;
                    }
                }
                else
                {
                    clicking = false;
                }

                instance.keys[2] = player.equipment.secondary;
                instance.keys[3] = player.stance.crouch;
                instance.keys[4] = player.stance.prone;
                instance.keys[5] = player.stance.sprint;
                instance.keys[6] = player.animator.leanLeft;
                instance.keys[7] = player.animator.leanRight;
                instance.keys[8] = false;

                for (int i = 0; i < (int)ControlsSettings.NUM_PLUGIN_KEYS; i++)
                {
                    int num = instance.keys.Length - ControlsSettings.NUM_PLUGIN_KEYS + i;
                    instance.keys[num] = Input.GetKey(ControlsSettings.getPluginKeyCode(i));
                }

                Analog = (byte)(player.movement.horizontal << 4 | player.movement.vertical);

                player.life.simulate(instance.simulation);
                player.stance.simulate(instance.simulation, player.stance.crouch, player.stance.prone, player.stance.sprint);

                Pitch = player.look.pitch;
                Yaw   = player.look.yaw;

                player.movement.simulate(instance.simulation, 0, player.movement.horizontal - 1, player.movement.vertical - 1, player.look.look_x, player.look.look_y, player.movement.jump, player.stance.sprint, Vector3.zero, PlayerInput.RATE);

                ClientSequence++;

                PlayerInputPacket playerInputPacket;

                if (player.stance.stance == EPlayerStance.DRIVING)
                {
                    playerInputPacket = new DrivingPlayerInputPacket();
                }

                else
                {
                    playerInputPacket = new WalkingPlayerInputPacket();
                }

                playerInputPacket.sequence         = ClientSequence;
                playerInputPacket.recov            = instance.recov;
                playerInputPacket.clientsideInputs = new List <RaycastInfo>();

                if (MiscOptions.PunchSilentAim)
                {
                    OV_DamageTool.OVType = OverrideType.PlayerHit;
                }

                RaycastInfo raycast = DamageTool.raycast(new Ray(player.look.aim.position, player.look.aim.forward), 6f,
                                                         RayMasks.DAMAGE_SERVER);

                OV_DamageTool.OVType = OverrideType.None;

                if (MiscOptions.PunchAura && !player.equipment.isSelected && !(raycast.player == null && raycast.vehicle == null && raycast.zombie == null && raycast.animal == null))
                {
                    if (Count % 6 == 0)
                    {
                        playerInputPacket.clientsideInputs.Add(raycast);
                        instance.keys[1] = true;
                    }

                    else
                    {
                        instance.keys[1] = false;
                    }
                }

                ushort num2 = 0;

                for (byte b = 0; b < instance.keys.Length; b++)
                {
                    if (instance.keys[b])
                    {
                        num2 |= (ushort)(1 << b);
                    }
                }

                playerInputPacket.keys = num2;

                if (playerInputPacket is DrivingPlayerInputPacket drivingPlayerInputPacket)
                {
                    InteractableVehicle vehicle = player.movement.getVehicle();
                    if (vehicle != null)
                    {
                        Transform transform = vehicle.transform;
                        drivingPlayerInputPacket.position = vehicle.asset.engine == EEngine.TRAIN
                                                    ? new Vector3(vehicle.roadPosition, 0f, 0f)
                                                    : transform.position;

                        drivingPlayerInputPacket.angle_x =
                            MeasurementTool.angleToByte2(transform.rotation.eulerAngles.x);
                        drivingPlayerInputPacket.angle_y =
                            MeasurementTool.angleToByte2(transform.rotation.eulerAngles.y);
                        drivingPlayerInputPacket.angle_z =
                            MeasurementTool.angleToByte2(transform.rotation.eulerAngles.z);
                        drivingPlayerInputPacket.speed        = (byte)(Mathf.Clamp(vehicle.speed, -100f, 100f) + 128f);
                        drivingPlayerInputPacket.physicsSpeed =
                            (byte)(Mathf.Clamp(vehicle.physicsSpeed, -100f, 100f) + 128f);
                        drivingPlayerInputPacket.turn = (byte)(vehicle.turn + 1);
                    }
                }
                else
                {
                    WalkingPlayerInputPacket walkingPlayerInputPacket = playerInputPacket as WalkingPlayerInputPacket;

                    walkingPlayerInputPacket.analog = Analog;

                    walkingPlayerInputPacket.position = instance.transform.localPosition;

                    var inputX = GetInputX(OptimizationVariables.MainPlayer.movement);
                    var inputY = GetInputY(OptimizationVariables.MainPlayer.movement);

                    if (MiscOptions.Spinbot && spinStances.Contains(OptimizationVariables.MainPlayer.stance.stance))
                    {
                        // Ghetto movement fix
                        if (inputX == 0 && inputY == 0)
                        {
                            walkingPlayerInputPacket.yaw = MiscOptions.StaticSpinbotYaw ? MiscOptions.SpinbotYaw : NextSpinbotYaw(MiscOptions.SpinbotYaw);
                        }
                        else
                        {
                            // use walkSpin bool to phase between actual angle and inverted angle to spin while walking
                            // and have fixed movement; only way we can do it with the d-pad like controls.
                            if (!walkSpin)
                            {
                                // Flip x/y input to account for reversed yaw (where intended movement direction will be reversed)
                                inputY *= -1;
                                inputX *= -1;
                                // Reverse yaw to spin while moving
                                walkingPlayerInputPacket.yaw    = ReverseAngle180(Yaw);
                                walkingPlayerInputPacket.analog = (byte)(((byte)(inputX + 1)) << 4 | (byte)(inputY + 1));
                                walkSpin = true;
                            }
                            else
                            {
                                walkingPlayerInputPacket.yaw = Yaw;
                                walkSpin = false;
                            }
                        }

                        walkingPlayerInputPacket.pitch = MiscOptions.StaticSpinbotPitch ? MiscOptions.SpinbotPitch : NextSpinbotPitch(MiscOptions.SpinbotPitch);
                    }
                    else
                    {
                        walkingPlayerInputPacket.yaw   = Yaw;
                        walkingPlayerInputPacket.pitch = Pitch;
                    }
                }

                Packets.Add(playerInputPacket);

                player.equipment.simulate(instance.simulation, instance.keys[1], player.equipment.secondary, player.stance.sprint);
                player.animator.simulate(instance.simulation, player.animator.leanLeft, player.animator.leanRight);

                SetSim(instance, GetSim(instance) + 1);
            }
        public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
        {
            try
            {
                TemplateObject spawned = null;
                LocationTag    loc     = LocationTag.For(entry.GetArgument(queue, 1));
                if (loc == null)
                {
                    queue.HandleError(entry, "Invalid location!");
                    return;
                }
                string     targetAssetType = entry.GetArgument(queue, 0).ToLowerFast();
                EntityType etype           = EntityType.ValueOf(targetAssetType);
                if (etype == null)
                {
                    queue.HandleError(entry, "Invalid entity type!");
                    return;
                }
                if (etype.Type == EntityAssetType.ZOMBIE)
                {
                    Vector3 vec3    = loc.ToVector3();
                    byte    reg     = 0; // TODO: Optionally specifiable
                    float   closest = float.MaxValue;
                    for (int r = 0; r < LevelZombies.zombies.Length; r++)
                    {
                        for (int i = 0; i < LevelZombies.zombies[r].Count; i++)
                        {
                            float dist = (LevelZombies.zombies[r][i].point - vec3).sqrMagnitude;
                            if (dist < closest)
                            {
                                closest = dist;
                                reg     = (byte)r;
                            }
                        }
                    }
                    ZombieManager.manager.addZombie(reg, 0, 0, 0, 0, 0, 0, 0, 0, vec3, 0, false);
                    Zombie zombie = ZombieManager.regions[reg].zombies[ZombieManager.regions[reg].zombies.Count - 1];
                    // TODO: Make this actually work! (See complaints file!)

                    /*
                     * foreach (SteamPlayer player in PlayerTool.getSteamPlayers())
                     * {
                     *  ZombieManager.manager.channel.openWrite();
                     *  ZombieManager.manager.channel.write(reg);
                     *  ZombieManager.manager.channel.write((ushort)1);
                     *  ZombieManager.manager.channel.write(new object[]
                     *      {
                     *          zombie.type,
                     *          (byte)zombie.speciality,
                     *          zombie.shirt,
                     *          zombie.pants,
                     *          zombie.hat,
                     *          zombie.gear,
                     *          zombie.move,
                     *          zombie.idle,
                     *          zombie.transform.position,
                     *          MeasurementTool.angleToByte(zombie.transform.rotation.eulerAngles.y),
                     *          zombie.isDead
                     *      });
                     *  ZombieManager.manager.channel.closeWrite("tellZombies", player.playerID.steamID, ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER);
                     * }
                     */
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully spawned a zombie at " + TagParser.Escape(loc.ToString()) + "! (WARNING: IT WILL BE INVISIBLE CURRENTLY - SEE THE COMPLAINTS FILE)");
                    }
                    spawned = new ZombieTag(zombie);
                }
                else if (etype.Type == EntityAssetType.ANIMAL)
                {
                    AnimalAssetTag asset = AnimalAssetTag.For(targetAssetType);
                    if (asset == null)
                    {
                        queue.HandleError(entry, "Invalid animal type!");
                        return;
                    }
                    // TODO: Make this bit optional!
                    RaycastHit rch;
                    while (Physics.Raycast(loc.ToVector3(), new Vector3(0, 1, 0), out rch, 5))
                    {
                        loc.Y += 3;
                    }
                    // END TODO
                    AnimalManager.manager.addAnimal(asset.Internal.id, loc.ToVector3(), 0, false);
                    Animal animal = AnimalManager.animals[AnimalManager.animals.Count - 1];
                    foreach (SteamPlayer player in PlayerTool.getSteamPlayers())
                    {
                        AnimalManager.manager.channel.openWrite();
                        AnimalManager.manager.channel.write((ushort)1);
                        AnimalManager.manager.channel.write(new object[]
                        {
                            animal.id,
                            animal.transform.position,
                            MeasurementTool.angleToByte(animal.transform.rotation.eulerAngles.y),
                            animal.isDead
                        });
                        AnimalManager.manager.channel.closeWrite("tellAnimals", player.playerID.steamID, ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER);
                    }
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "! (" + animal.gameObject.GetInstanceID() + ")");
                    }
                    spawned = new AnimalTag(animal);
                }
                else if (etype.Type == EntityAssetType.VEHICLE)
                {
                    VehicleAssetTag asset = VehicleAssetTag.For(targetAssetType);
                    if (asset == null)
                    {
                        queue.HandleError(entry, "Invalid vehicle type!");
                        return;
                    }
                    // TODO: Make this bit optional!
                    RaycastHit rch;
                    while (Physics.Raycast(loc.ToVector3(), new Vector3(0, 1, 0), out rch, 5))
                    {
                        loc.Y += 3;
                    }
                    // END TODO
                    VehicleManager.spawnVehicle(asset.Internal.id, loc.ToVector3(), Quaternion.identity);
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    // TODO: Get the vehicle entity!
                }
                else if (etype.Type == EntityAssetType.WORLD_OBJECT)
                {
                    WorldObjectAssetTag asset = WorldObjectAssetTag.For(targetAssetType);
                    if (asset == null)
                    {
                        queue.HandleError(entry, "Invalid world object type!");
                        return;
                    }
                    LevelObjects.addObject(loc.ToVector3(), Quaternion.identity, Vector3.one, asset.Internal.id, asset.Internal.name, asset.Internal.GUID, ELevelObjectPlacementOrigin.MANUAL);
                    // TODO: Network!
                    entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "! (WARNING: IT WILL BE INVISIBLE CURRENTLY - SEE THE COMPLAINTS FILE)");
                    // TODO: Get the world entity!
                }
                else if (etype.Type == EntityAssetType.ITEM)
                {
                    ItemAssetTag asset = ItemAssetTag.For(targetAssetType);
                    if (asset == null)
                    {
                        queue.HandleError(entry, "Invalid item type!");
                        return;
                    }
                    byte x;
                    byte y;
                    if (Regions.tryGetCoordinate(loc.ToVector3(), out x, out y))
                    {
                        Item     item = new Item(asset.Internal.id, 1, asset.Internal.quality);
                        ItemData data = new ItemData(item, ++ItemManager.instanceCount, loc.ToVector3(), Dedicator.isDedicated);
                        ItemManager.regions[x, y].items.Add(data);
                        ItemModelTracker.Track(data, loc.ToVector3());
                        ItemManager.manager.channel.send("tellItem", ESteamCall.CLIENTS, x, y, ItemManager.ITEM_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                        {
                            x,
                            y,
                            item.id,
                            item.amount,
                            item.quality,
                            item.state,
                            loc.ToVector3()
                        });
                        if (entry.ShouldShowGood(queue))
                        {
                            entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
                        }
                        // TODO: Get the item entity!
                    }
                    else
                    {
                        queue.HandleError(entry, "Trying to spawn item outside any valid item regions!");
                    }
                }
                else if (etype.Type == EntityAssetType.BARRICADE)
                {
                    ItemAssetTag asset = ItemAssetTag.For(targetAssetType.Substring("barricade_".Length));
                    if (asset == null || !(asset.Internal is ItemBarricadeAsset))
                    {
                        queue.HandleError(entry, "Invalid item barricade type!");
                        return;
                    }
                    Barricade barric = new Barricade(asset.Internal.id);
                    BarricadeManager.dropBarricade(barric, null, loc.ToVector3(), 0f, 0f, 0f, CSteamID.Nil.m_SteamID, CSteamID.Nil.m_SteamID);
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    // TODO: Get the game object!
                }
                else if (etype.Type == EntityAssetType.STRUCTURE)
                {
                    ItemAssetTag asset = ItemAssetTag.For(targetAssetType.Substring("structure_".Length));
                    if (asset == null || !(asset.Internal is ItemStructureAsset))
                    {
                        queue.HandleError(entry, "Invalid item structure type!");
                        return;
                    }
                    StructureManager.dropStructure(new Structure(asset.Internal.id), loc.ToVector3(), 0f, 0f, 0f, CSteamID.Nil.m_SteamID, CSteamID.Nil.m_SteamID);
                    if (entry.ShouldShowGood(queue))
                    {
                        entry.Good(queue, "Successfully spawned a " + TagParser.Escape(asset.ToString()) + " at " + TagParser.Escape(loc.ToString()) + "!");
                    }
                    // TODO: Get the game object!
                }
                else
                {
                    queue.HandleError(entry, "Invalid or unspawnable entity type!");
                    return;
                }
                if (spawned != null)
                {
                    queue.SetVariable("spawned", spawned);
                }
            }
            catch (Exception ex) // TODO: Necessity?
            {
                queue.HandleError(entry, "Failed to spawn entity: " + ex.ToString());
            }
        }
Example #25
0
        public static Transform dropBarricade(Barricade barricade, Transform hit, Vector3 point, float angle_x, float angle_y, float angle_z, ulong owner, ulong group)
        {
            // #Nelson doesn't know how to optimize!!!
            ItemBarricadeAsset itemBarricadeAsset = (ItemBarricadeAsset)Assets.find(EAssetType.ITEM, barricade.id);
            Transform          result             = null;

            if (itemBarricadeAsset == null)
            {
                return(result);
            }
            Vector3 eulerAngles = BarricadeManager.getRotation(itemBarricadeAsset, angle_x, angle_y, angle_z).eulerAngles;

            angle_x = (float)(Mathf.RoundToInt(eulerAngles.x / 2f) * 2);
            angle_y = (float)(Mathf.RoundToInt(eulerAngles.y / 2f) * 2);
            angle_z = (float)(Mathf.RoundToInt(eulerAngles.z / 2f) * 2);
            byte            b3;
            byte            b4;
            BarricadeRegion barricadeRegion2;
            bool            cancel = false;

            if (hit != null && hit.transform.CompareTag("Vehicle")) // Placed on vehicle???
            {
                byte            b;
                byte            b2;
                ushort          num;
                BarricadeRegion barricadeRegion;
                if (!BarricadeManager.tryGetPlant(hit, out b, out b2, out num, out barricadeRegion))
                {
                    return(result);
                }
                BarricadeData barricadeData = new BarricadeData(barricade, point, MeasurementTool.angleToByte(angle_x), MeasurementTool.angleToByte(angle_y), MeasurementTool.angleToByte(angle_z), owner, @group, Provider.time);
                ServerEvents.RunBarricadeCreated(barricadeData, ref cancel);
                if (cancel)
                {
                    return(null);
                }
                barricadeRegion.barricades.Add(barricadeData);
                uint num2 = (uint)typeof(BarricadeManager).GetField("", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) + 1u;
                result = (Transform)typeof(BarricadeManager).GetMethod("spawnBarricade", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(BarricadeManager.instance, new object[] { barricadeRegion, barricade.id, barricade.state, barricadeData.point, barricadeData.angle_x, barricadeData.angle_y, barricadeData.angle_z, 100, barricadeData.owner, barricadeData.@group, num2 });
                BarricadeManager.instance.channel.send("tellBarricade", ESteamCall.OTHERS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                {
                    b,
                    b2,
                    num,
                    barricade.id,
                    barricade.state,
                    barricadeData.point,
                    barricadeData.angle_x,
                    barricadeData.angle_y,
                    barricadeData.angle_z,
                    barricadeData.owner,
                    barricadeData.@group,
                    num2
                });
            }
            else if (Regions.tryGetCoordinate(point, out b3, out b4) && BarricadeManager.tryGetRegion(b3, b4, 65535, out barricadeRegion2))
            {
                BarricadeData barricadeData2 = new BarricadeData(barricade, point, MeasurementTool.angleToByte(angle_x), MeasurementTool.angleToByte(angle_y), MeasurementTool.angleToByte(angle_z), owner, @group, Provider.time);
                ServerEvents.RunBarricadeCreated(barricadeData2, ref cancel);
                if (cancel)
                {
                    return(null);
                }
                barricadeRegion2.barricades.Add(barricadeData2);
                uint num3 = (uint)typeof(BarricadeManager).GetField("", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) + 1u;
                result = (Transform)typeof(BarricadeManager).GetMethod("spawnBarricade", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(BarricadeManager.instance, new object[] { barricadeRegion2, barricade.id, barricade.state, barricadeData2.point, barricadeData2.angle_x, barricadeData2.angle_y, barricadeData2.angle_z, 100, barricadeData2.owner, barricadeData2.@group, num3 });
                BarricadeManager.instance.channel.send("tellBarricade", ESteamCall.OTHERS, b3, b4, BarricadeManager.BARRICADE_REGIONS, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[]
                {
                    b3,
                    b4,
                    65535,
                    barricade.id,
                    barricade.state,
                    barricadeData2.point,
                    barricadeData2.angle_x,
                    barricadeData2.angle_y,
                    barricadeData2.angle_z,
                    barricadeData2.owner,
                    barricadeData2.@group,
                    num3
                });
            }
            return(result);
        }
Example #26
0
 public void Create(ref MeasurementTool tool, List <MasterItem> items = null, List <MasterCustomer> customers = null)
 {
     /*
      * int workloadSize = 10_000;
      * MasterCustomer[] cusArray = MasterCustomer.GenerateCustomers(500, "createNorm", 0).ToArray();
      * MasterItem[] itemArray = items.ToArray();
      *
      * Random new_or_oldSelector = new Random(4573);
      * Random customerGenSelector = new Random(867542);
      * Random satisfySelector = new Random(2678);
      * Random storeSelector = new Random(236786);
      * Random diffItemSelector = new Random(83457);
      * Random quantityItemSelector = new Random(6526);
      * Random itemSelector = new Random(572);
      * Random dateSelector = new Random(6762);
      * DateTime startDate = new DateTime(2020, 1, 2);
      * DateTime endDate = new DateTime(2020, 5, 28);
      * int range = (endDate - startDate).Days;
      *
      * for (int i = 0; i < workloadSize; i++)
      * {
      *  int new_old = new_or_oldSelector.Next(0, 2);
      *  string title = new_old == 0 ? "PostgreSQL,Sale,Norm,Create,New user" : "PostgreSQL,Sale,Norm,Create,Existing user";
      *  Customer customer = null;
      *  //New
      *  if (new_old == 0)
      *  {
      *      MasterCustomer tmpcustomer = cusArray[customerGenSelector.Next(0, cusArray.Length)];
      *      customer = new Customer
      *      {
      *          ID = ObjectId.GenerateNewId(),
      *          Age = tmpcustomer.Age,
      *          Email = tmpcustomer.Email,
      *          Gender = tmpcustomer.Gender
      *      };
      *      tool.Stopwatch.Start();
      *      Customers.InsertOne(customer);
      *      tool.Stopwatch.Stop();
      *  }
      *  //Exisiting
      *  else
      *  {
      *      customer = Customers.AsQueryable().Sample(1).FirstOrDefault();
      *  }
      *  //Sale creation
      *  Sale sale = new Sale
      *  {
      *      CustomerID = customer.ID,
      *      SaleDate = startDate.AddDays(dateSelector.Next(range)),
      *      CouponUsed = false,
      *      PurchaseMethod = "Card",
      *      SatisfactoryNumber = satisfySelector.Next(0, 10),
      *      StoreLocation = StoreLocation.Locations[storeSelector.Next(0, 8)]
      *  };
      *  tool.Stopwatch.Start();
      *  Sales.InsertOne(sale);
      *  tool.Stopwatch.Stop();
      *  //Item selection and Saleitem creation
      *  List<string> usedItems = new List<string>();
      *  int diffItems = diffItemSelector.Next(1, 5);
      *  for (int j = 0; j < diffItems; j++)
      *  {
      *      int itemIndex = itemSelector.Next(0, itemArray.Length);
      *      if (!usedItems.Contains(itemArray[itemIndex].Name))
      *      {
      *          // Find item
      *          usedItems.Add(itemArray[itemIndex].Name);
      *          int itemQuant = quantityItemSelector.Next(1, 5);
      *          Item foundItem = Items.Find(item => item.Name.Equals(itemArray[itemIndex].Name)).FirstOrDefault();
      *          // Create SaleItem
      *          SaleItem saleitem = new SaleItem
      *          {
      *              ItemId = foundItem.ID,
      *              SaleId = sale.ID,
      *              Price = foundItem.Price,
      *              Quantity = itemQuant
      *          };
      *          tool.Stopwatch.Start();
      *          SaleItems.InsertOne(saleitem);
      *          tool.Stopwatch.Stop();
      *      }
      *      else
      *          break;
      *  }
      *  tool.SaveAndReset(title);
      * }*/
 }