public VMAvatar CreateAvatar()
        {
            var avatar = new VMAvatar();

            this.InitWorldComponent(avatar.WorldUI);
            Blueprint.AddAvatar(avatar.WorldUI);
            VM.AddEntity(avatar);
            return(avatar);
        }
        public VMAvatar CreateAvatar()
        {
            var avatar = new VMAvatar(TSO.Content.Content.Get().WorldObjects.Get(VMAvatar.TEMPLATE_PERSON));

            this.InitWorldComponent(avatar.WorldUI);
            Blueprint.AddAvatar((AvatarComponent)avatar.WorldUI);
            VM.AddEntity(avatar);
            return(avatar);
        }
Example #3
0
        public VMMultitileGroup CreateObjectInstance(UInt32 GUID, LotTilePos pos, Direction direction, short MainStackOBJ, short MainParam, bool ghostImage)
        {
            VMMultitileGroup group = new VMMultitileGroup();
            var objDefinition      = FSO.Content.Content.Get().WorldObjects.Get(GUID);

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

            var master = objDefinition.OBJ.MasterID;

            if (master != 0 && objDefinition.OBJ.SubIndex == -1)
            {
                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 = FSO.Content.Content.Get().WorldObjects.Get(objd[i].GUID);
                        if (subObjDefinition != null)
                        {
                            var worldObject = new ObjectComponent(subObjDefinition);
                            var vmObject    = new VMGameObject(subObjDefinition, worldObject);
                            vmObject.GhostImage = ghostImage;
                            if (UseWorld)
                            {
                                Blueprint.AddObject(worldObject);
                            }

                            vmObject.MasterDefinition = objDefinition.OBJ;
                            vmObject.UseTreeTableOf(objDefinition);

                            vmObject.MainParam    = MainParam;
                            vmObject.MainStackOBJ = MainStackOBJ;
                            group.AddObject(vmObject);

                            vmObject.MultitileGroup = group;
                            if (!ghostImage)
                            {
                                VM.AddEntity(vmObject);
                            }
                        }
                    }
                }

                group.Init(this);
                VMPlacementError couldPlace = group.ChangePosition(pos, direction, this).Status;
                return(group);
            }
            else
            {
                if (objDefinition.OBJ.ObjectType == OBJDType.Person) //person
                {
                    var vmObject = new VMAvatar(objDefinition);
                    vmObject.MultitileGroup = group;
                    group.AddObject(vmObject);

                    vmObject.GhostImage = ghostImage;
                    if (!ghostImage)
                    {
                        VM.AddEntity(vmObject);
                    }

                    if (UseWorld)
                    {
                        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.AddObject(vmObject);

                    vmObject.GhostImage = ghostImage;
                    if (!ghostImage)
                    {
                        VM.AddEntity(vmObject);
                    }
                    if (UseWorld && Blueprint != null)
                    {
                        Blueprint.AddObject(worldObject);
                    }

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

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

                    return(group);
                }
            }
        }
        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);
                }
            }
        }