Exemplo n.º 1
0
        public VMEntity CreateObjectInstance(UInt32 GUID, short x, short y, sbyte level, Direction direction)
        {
            var objDefinition = TSO.Content.Content.Get().WorldObjects.Get(GUID);

            if (objDefinition == null)
            {
                return(null);
            }

            var master = objDefinition.OBJ.MasterID;

            if (master != 0)
            {
                var objd = objDefinition.Resource.List <OBJD>();
                VMMultitileGroup group = new VMMultitileGroup();

                for (int i = 0; i < objd.Count; i++)
                {
                    if (objd[i].MasterID == master && objd[i].SubIndex != -1) //if sub-part of this object, make it!
                    {
                        var subObjDefinition = TSO.Content.Content.Get().WorldObjects.Get(objd[i].GUID);
                        if (subObjDefinition != null)
                        {
                            var worldObject = new ObjectComponent(subObjDefinition);
                            var vmObject    = new VMGameObject(subObjDefinition, worldObject);
                            vmObject.MasterDefinition = objDefinition.OBJ;
                            vmObject.UseTreeTableOf(objDefinition);
                            group.Objects.Add(vmObject);

                            VM.AddEntity(vmObject);

                            vmObject.MultitileGroup = group;
                        }
                    }
                }

                group.ChangePosition(x, y, level, direction, this);
                return((VMGameObject)group.Objects[0]);
            }
            else
            {
                if (objDefinition.OBJ.ObjectType == OBJDType.Person) //person
                {
                    var vmObject = new VMAvatar(objDefinition);
                    VM.AddEntity(vmObject);

                    //this.InitWorldComponent(vmObject.WorldUI);
                    Blueprint.AddAvatar((AvatarComponent)vmObject.WorldUI);

                    vmObject.SetPosition(x, y, level, direction, this);
                    return(vmObject);
                }
                else
                {
                    var worldObject = new ObjectComponent(objDefinition);
                    var vmObject    = new VMGameObject(objDefinition, worldObject);

                    VM.AddEntity(vmObject);

                    vmObject.SetPosition(x, y, level, direction, this);
                    return(vmObject);
                }
            }
        }
Exemplo n.º 2
0
        public VMMultitileGroup CreateObjectInstance(UInt32 GUID, LotTilePos pos, Direction direction, short MainStackOBJ, short MainParam)
        {
            VMMultitileGroup group = new VMMultitileGroup();
            var objDefinition = TSO.Content.Content.Get().WorldObjects.Get(GUID);
            if (objDefinition == null)
            {
                return null;
            }

            var master = objDefinition.OBJ.MasterID;
            if (master != 0)
            {
                group.MultiTile = true;
                var objd = objDefinition.Resource.List<OBJD>();

                for (int i = 0; i < objd.Count; i++)
                {
                    if (objd[i].MasterID == master && objd[i].SubIndex != -1) //if sub-part of this object, make it!
                    {
                        var subObjDefinition = TSO.Content.Content.Get().WorldObjects.Get(objd[i].GUID);
                        if (subObjDefinition != null)
                        {
                            var worldObject = new ObjectComponent(subObjDefinition);
                            var vmObject = new VMGameObject(subObjDefinition, worldObject);
                            vmObject.MasterDefinition = objDefinition.OBJ;
                            vmObject.UseTreeTableOf(objDefinition);

                            vmObject.MainParam = MainParam;
                            vmObject.MainStackOBJ = MainStackOBJ;
                            group.Objects.Add(vmObject);

                            vmObject.MultitileGroup = group;
                            VM.AddEntity(vmObject);

                        }
                    }
                }

                group.Init(this);
                VMPlacementError couldPlace = group.ChangePosition(pos, direction, this);
                if (couldPlace != VMPlacementError.Success);
                return group;
            }
            else
            {
                if (objDefinition.OBJ.ObjectType == OBJDType.Person) //person
                {
                    var vmObject = new VMAvatar(objDefinition);
                    vmObject.MultitileGroup = group;
                    group.Objects.Add(vmObject);
                    VM.AddEntity(vmObject);

                    Blueprint.AddAvatar((AvatarComponent)vmObject.WorldUI);

                    vmObject.MainParam = MainParam;
                    vmObject.MainStackOBJ = MainStackOBJ;

                    group.Init(this);
                    vmObject.SetPosition(pos, direction, this);

                    return group;
                }
                else
                {
                    var worldObject = new ObjectComponent(objDefinition);
                    var vmObject = new VMGameObject(objDefinition, worldObject);

                    vmObject.MultitileGroup = group;
                    group.Objects.Add(vmObject);

                    VM.AddEntity(vmObject);

                    vmObject.MainParam = MainParam;
                    vmObject.MainStackOBJ = MainStackOBJ;

                    group.Init(this);
                    vmObject.SetPosition(pos, direction, this);

                    return group;
                }
            }
        }
Exemplo n.º 3
0
        public VMEntity CreateObjectInstance(UInt32 GUID, short x, short y, sbyte level, Direction direction)
        {
            var objDefinition = TSO.Content.Content.Get().WorldObjects.Get(GUID);
            if (objDefinition == null)
            {
                return null;
            }

            var master = objDefinition.OBJ.MasterID;
            if (master != 0)
            {
                var objd = objDefinition.Resource.List<OBJD>();
                VMMultitileGroup group = new VMMultitileGroup();

                for (int i = 0; i < objd.Count; i++)
                {
                    if (objd[i].MasterID == master && objd[i].SubIndex != -1) //if sub-part of this object, make it!
                    {
                        var subObjDefinition = TSO.Content.Content.Get().WorldObjects.Get(objd[i].GUID);
                        if (subObjDefinition != null)
                        {
                            var worldObject = new ObjectComponent(subObjDefinition);
                            var vmObject = new VMGameObject(subObjDefinition, worldObject);
                            vmObject.MasterDefinition = objDefinition.OBJ;
                            vmObject.UseTreeTableOf(objDefinition);
                            group.Objects.Add(vmObject);

                            VM.AddEntity(vmObject);

                            vmObject.MultitileGroup = group;
                        }
                    }
                }

                group.ChangePosition(x, y, level, direction, this);
                return (VMGameObject)group.Objects[0];
            }
            else
            {
                if (objDefinition.OBJ.ObjectType == OBJDType.Person) //person
                {
                    var vmObject = new VMAvatar(objDefinition);
                    VM.AddEntity(vmObject);

                    //this.InitWorldComponent(vmObject.WorldUI);
                    Blueprint.AddAvatar((AvatarComponent)vmObject.WorldUI);

                    vmObject.SetPosition(x, y, level, direction, this);
                    return vmObject;
                }
                else
                {
                    var worldObject = new ObjectComponent(objDefinition);
                    var vmObject = new VMGameObject(objDefinition, worldObject);

                    VM.AddEntity(vmObject);

                    vmObject.SetPosition(x, y, level, direction, this);
                    return vmObject;
                }
            }
        }