コード例 #1
0
 public DynamicAreaWriter(DynamicArea entity, BaseWriterContainer parent)
     : base(entity, parent)
 {
     _dynamicObject = new DynamicSource(entity.ProductRule);
     _dynamicObject.SetParam("RowIndex", p => p);
     _dynamicObject.SetParam("RowNum", p => p + 1);
 }
コード例 #2
0
        public List <BaseEntity> GetAllContainers(bool reset = false)
        {
            if (reset)
            {
                allContainers = null;
            }
            if (allContainers != null)
            {
                return(allContainers);
            }

            DynamicArea entity = Entity as DynamicArea;

            allContainers = new List <BaseEntity>();
            DataTable dt = this.Source != null ? this.Source.Table : null;

            if (dt == null)
            {
                return(allContainers);
            }
            for (int rowIndex = 0; rowIndex < dt.Rows.Count; rowIndex++)
            {
                for (int i = 0; i < entity.Tables.Length; i++)
                {
                    Table tmpTable = entity.Tables[i];
                    Table table    = (Table)tmpTable.Clone(tmpTable.ProductRule, tmpTable.Container);
                    //调整行位置(相对)
                    table.Location.RowIndex = entity.Location.RowCount * rowIndex + table.Location.RowIndex;
                    //获取数据源
                    table.SourceName = _dynamicObject.GetDynamicValue(table.SourceName, rowIndex);
                    //Source source = entity.GetDynamicSource(table.SourceName, rowIndex);
                    //if (source != null)
                    //{
                    //    table.Source = source;
                    //}
                    allContainers.Add(table);
                }

                for (int i = 0; i < entity.Cells.Length; i++)
                {
                    Cell tmpCell = entity.Cells[i];
                    Cell cell    = (Cell)tmpCell.Clone(tmpCell.ProductRule, tmpCell.Container);
                    //调整行位置(相对)
                    cell.Location.RowIndex = entity.Location.RowCount * rowIndex + cell.Location.RowIndex;
                    if (!string.IsNullOrEmpty(cell.SourceName))
                    {
                        //Source source = entity.GetDynamicSource(cell.SourceName, rowIndex);
                        //if (source != null) cell.Source = source;
                        cell.SourceName = _dynamicObject.GetDynamicValue(cell.SourceName, rowIndex);
                    }
                    if (!string.IsNullOrEmpty(cell.Value))
                    {
                        cell.Value = _dynamicObject.GetDynamicValue(cell.Value, rowIndex);
                    }
                    allContainers.Add(cell);
                }
            }
            return(allContainers);
        }
コード例 #3
0
 public MruDynamicObject(uint apiId, int modelid, Vector3 position, Vector3 rotation = new Vector3(),
                         int worldid        = -1, int interiorid  = -1, BasePlayer player = null, float streamdistance = 200,
                         float drawdistance = 0, DynamicArea area = null, int priority    = 0, uint estateId           = 0) : base(modelid,
                                                                                                                                   position, rotation, worldid, interiorid, player, streamdistance, drawdistance, area, priority)
 {
     ApiId = apiId;
     Object3DText(modelid, position);
 }
コード例 #4
0
    private void OnPlayerEnterDynamicArea(Player player, DynamicArea area)
    {
        var entry = area.GetComponentInParent <EntryPoint>();

        player.Position     = entry.Entry.Position;
        player.Interior     = entry.Entry.Interior;
        player.VirtualWorld = entry.Entry.VirtualWorld;
    }
コード例 #5
0
        public static async void DestroyCommand(BasePlayer player)
        {
            player.SendClientMessage($"Delay...");
            await Task.Delay(100);

            _area?.Dispose();

            player.SendClientMessage(_area == null ? "Create an area with /create first." : "Area destroyed.");
            _area = null;
        }
コード例 #6
0
        internal void OnPlayerLeaveDynamicArea(int playerid, int areaid)
        {
            var area = DynamicArea.Find(areaid);

            if (area == null)
            {
                return;
            }

            OnPlayerLeaveDynamicArea(area, new PlayerEventArgs(BasePlayer.FindOrCreate(playerid)));
        }
コード例 #7
0
        public override IList <OutputNode> GetNodes()
        {
            DynamicArea       entity = Entity as DynamicArea;
            List <OutputNode> nodes  = new List <OutputNode>();

            //allContainers = GetAllContainers();
            for (int i = 0; i < Components.Count; i++)
            {
                nodes.AddRange(Components[i].GetNodes());
            }
            return(nodes);
        }
コード例 #8
0
        public static async void CreateCommand(BasePlayer player, float size = 5)
        {
            player.SendClientMessage($"Delay...");
            await Task.Delay(100);

            var position = player.Position;

            _area?.Dispose();
            _area        = DynamicArea.CreateSphere(position, size);
            _area.Enter += (sender, args) => args.Player.SendClientMessage("Enter");
            _area.Leave += (sender, args) => args.Player.SendClientMessage("Leave");
            player.SendClientMessage($"Area with size {size} created at {position}.");
            player.SendClientMessage("Check - " + _area.Position);
        }
コード例 #9
0
        protected override void CreatingSubWriters()
        {
            DynamicArea dynamicArea = (DynamicArea)base.Entity;

            foreach (var container in this.GetAllContainers())
            {
                Table table = container as Table;

                if (table != null && table.CopyFill)
                {
                    Components.Add(new TableWriter(table as Table, this));
                }
                else if (container is Cell)
                {
                    Components.Add(new CellWriter(container as Cell, this));
                }
            }
        }
コード例 #10
0
        private T GetItem <T>(int id) where T : IDynamicWorldObject
        {
            if (typeof(DynamicTextLabel).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicTextLabel.Find(id));
            }

            if (typeof(DynamicPickup).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicPickup.Find(id));
            }

            if (typeof(DynamicRaceCheckpoint).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicRaceCheckpoint.Find(id));
            }

            if (typeof(DynamicObject).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicObject.Find(id));
            }

            if (typeof(DynamicMapIcon).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicMapIcon.Find(id));
            }

            if (typeof(DynamicCheckpoint).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicCheckpoint.Find(id));
            }

            if (typeof(DynamicArea).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicArea.Find(id));
            }

            if (typeof(DynamicActor).IsAssignableFrom(typeof(T)))
            {
                return((T)(IDynamicWorldObject)DynamicActor.Find(id));
            }

            throw new Exception("Unknown dynamic world object type.");
        }
コード例 #11
0
        public override void PreWrite(WriteEventArgs args)
        {
            base.PreWrite(args);
            ISheet      exSheet     = args.ExSheet;
            DynamicArea dynamicArea = args.Entity as DynamicArea;

            if (dynamicArea == null)
            {
                return;
            }

            int baseRow = this.RowIndex;

            for (int i = 1; i < this.Count; i++)
            {
                for (int j = 0; j < dynamicArea.Location.RowCount; j++)
                {
                    NPOIExcelUtil.CopyRow(exSheet, baseRow + j, baseRow + j + dynamicArea.Location.RowCount * i);
                }
            }
        }
コード例 #12
0
ファイル: Chat.cs プロジェクト: SA-MP-Developer/SemiRP
        public static DynamicTextLabel CreateTmeTimer(String message, Vector3 position, float drawdistance, int time, Player attachedPlayer = null, Vehicle attachedVehicle = null, bool testLOS = false, int worldid = -1, int interiorid = -1, Player player = null, float streamdistance = 100, DynamicArea area = null, int priority = 0)
        {
            DynamicTextLabel dynamicTextLabel = new DynamicTextLabel(message, Constants.Chat.ME, position, drawdistance, attachedPlayer, attachedVehicle, testLOS, worldid, interiorid, player, streamdistance, area, priority);
            var timerKick = new Timer(time, false);

            timerKick.Tick += (senderPlayer, e) =>
            {
                dynamicTextLabel.Dispose();
            };
            return(dynamicTextLabel);
        }
コード例 #13
0
ファイル: Chat.cs プロジェクト: SA-MP-Developer/SemiRP
 public static DynamicTextLabel CreateTme(String message, Vector3 position, float drawdistance, Player attachedPlayer = null, Vehicle attachedVehicle = null, bool testLOS = false, int worldid = -1, int interiorid = -1, Player player = null, float streamdistance = 100, DynamicArea area = null, int priority = 0)
 {
     return(new DynamicTextLabel(message, Constants.Chat.ME, position, drawdistance, attachedPlayer, attachedVehicle, testLOS, worldid, interiorid, player, streamdistance, area, priority));
 }
コード例 #14
0
        /// <summary>
        ///     Raises the <see cref="E:SampSharp.GameMode.BaseMode.Initialized" /> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data. </param>
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            var vehicle = BaseVehicle.Create(VehicleModelType.Alpha, Vector3.Up * 15, 0, -1, -1);

            vehicle.GetDamageStatus(out var panels, out var doors, out var lights, out var tires);
            Console.WriteLine(panels.ToString());
            Console.WriteLine(doors.ToString());
            Console.WriteLine(lights.ToString());
            Console.WriteLine(tires.ToString());

            var streamer = Services.GetService <IStreamer>();

            Console.WriteLine("Service: " + streamer);

            var area =
                DynamicArea.CreatePolygon(new[]
            {
                Vector3.One + new Vector3(-10, -10),
                Vector3.One + new Vector3(10, -10),
                Vector3.One + new Vector3(10, 10),
                Vector3.One + new Vector3(-10, 10)
            }, -100.0f, 100.0f);

            Console.WriteLine("Area handle: " + area.Id);

            area.Enter += (sender, args) => args.Player.SendClientMessage("Entered polygon");
            area.Leave += (sender, args) => args.Player.SendClientMessage("Left polygon");

            var isValid  = area.IsValid;
            var position = area.Position;
            var points   = area.GetPoints().ToArray();

            Console.WriteLine($"area.IsValid = {isValid}, area.Position = {position}, Points = {string.Join(", ", points)}");

            var area2 = DynamicArea.CreateRectangle(0, 0, 20, 20);

            area2.Enter += (sender, args) => args.Player.SendClientMessage("Entered Rectangle");
            area2.Leave += (sender, args) => args.Player.SendClientMessage("Left Rectangle");

            var icon = new DynamicMapIcon(new Vector3(1500, -1500, 0), Color.Blue, MapIconType.Global, -1, -1, null, 300);

            Console.WriteLine(icon.Position);
            icon.Position = new Vector3(50, 50, 5);
            Console.WriteLine(icon.Position);

            var pickup = new DynamicPickup(1274, 23, new Vector3(0, 0, 3), 100f,
                                           new[] { 11, 22, 33, 44, 0, 55, 66, 77, 88, 99 }); //Dollar icon

            pickup.PickedUp += (sender, args) => args.Player.SendClientMessage(Color.White, "Picked Up");

            var pickup2 = new DynamicPickup(1274, 23, Vector3.One, 42);

            Console.WriteLine("World: {0}", string.Join(",", pickup.Worlds));
            Console.WriteLine("World: {0}", string.Join(",", pickup2.Worlds));

            var checkpoint = new DynamicCheckpoint(new Vector3(10, 10, 3));

            checkpoint.Enter += (sender, args) => args.Player.SendClientMessage(Color.White, "Entered CP");
            checkpoint.Leave += (sender, args) => args.Player.SendClientMessage(Color.White, "Left CP");

            var actor = new DynamicActor(100, new Vector3(20, 10, 5), 0);



            var racecheckpoint = new DynamicRaceCheckpoint(CheckpointType.Normal, new Vector3(-10, -10, 3), new Vector3());

            racecheckpoint.Enter += (sender, args) => args.Player.SendClientMessage(Color.White, "Entered RCP");
            racecheckpoint.Leave += (sender, args) => args.Player.SendClientMessage(Color.White, "Left RCP");

            new DynamicTextLabel("[I am maroon]", Color.Maroon, pickup.Position + new Vector3(0, 0, 1), 100.0f);

            var obj = new DynamicObject(12991, new Vector3(10, 10, 3));

            Console.WriteLine("obj position after spawn " + obj.Position);
            var offset = Vector3.One;

            obj.SetMaterialText(1, "Test", ObjectMaterialSize.X512X512, "Arial", 30, false, Color.Black, Color.White);
            obj.Move(obj.Position + -offset, 0.6f, obj.Rotation + new Vector3(0, 0, 25));
            obj.Moved += (sender, args) =>
            {
                Console.WriteLine("moved");
                obj.Move(obj.Position + (offset = -offset), 0.6f, obj.Rotation + new Vector3(0, 0, 25));
            };


            Console.WriteLine("Test error handling...");
            streamer.IsErrorCallbackEnabled = true;
            streamer.Error += (sender, args) => { Console.WriteLine("Error CB: " + args.Error); };
            streamer.PrintStackTraceOnError = true;
            streamer.ItemType[StreamType.MapIcon].GetArray(9999, StreamerDataType.Color, 1);
            Console.WriteLine("Messages should have appeared above.");
        }
コード例 #15
0
 /// <summary>
 ///     Registers types this <see cref="T:SampSharp.GameMode.Controllers.ITypeProvider" /> requires the system to use.
 /// </summary>
 public virtual void RegisterTypes()
 {
     DynamicArea.Register <DynamicArea>();
 }
コード例 #16
0
 protected virtual void OnPlayerLeaveDynamicArea(DynamicArea area, PlayerEventArgs e)
 {
     PlayerLeaveDynamicArea?.Invoke(area, e);
 }