Пример #1
0
 public void SetSelectors(OBJD objd, IffChunk active, OBJDSelector[] selectors)
 {
     Active = active;
     Definition = objd;
     SelectButton.Dock = DockStyle.Fill;
     SelectCombo.Dock = DockStyle.Fill;
     SelectButton.Visible = selectors.Length == 1;
     SelectCombo.Visible = selectors.Length > 1;
     Selectors = selectors;
     if (selectors.Length > 1)
     {
         SelectCombo.Items.Clear();
         SelectCombo.Items.Add("-- Not Selected --");
         int i = 1;
         OwnChange = true;
         SelectCombo.SelectedIndex = 0;
         foreach (var sel in selectors)
         {
             SelectCombo.Items.Add(sel);
             if (sel.FieldName != null && objd.GetPropertyByName<ushort>(sel.FieldName) == active.ChunkID)
                 SelectCombo.SelectedIndex = i;
             i++;
         }
         OwnChange = false;
     } else if (selectors.Length > 0)
     {
         var sel = selectors[0];
         if (sel.FieldName != null && objd.GetPropertyByName<ushort>(sel.FieldName) == active.ChunkID)
         {
             SelectButton.Text = "Selected as " + sel.Name;
             SelectButton.Enabled = false;
         } else
         {
             SelectButton.Text = "Select as " + sel.Name;
             SelectButton.Enabled = true;
         }
     }
     else
     {
         Enabled = false;
         Visible = false;
     }
 }
Пример #2
0
 //hilariously large switch case. there's got to be a better way
 public static short GetEntityDefinitionVar(OBJD objd, VMOBJDVariable var, VMStackFrame context)
 {
     switch (var)
     {
         case VMOBJDVariable.Version1:
             return (short)(objd.Version%0xFFFF);
         case VMOBJDVariable.Version2:
             return (short)(objd.Version>>16);
         case VMOBJDVariable.InitialStackSize:
             return (short)objd.StackSize;
         case VMOBJDVariable.BaseGraphic:
             return (short)objd.BaseGraphicID;
         case VMOBJDVariable.NumGraphics:
             return (short)objd.NumGraphics;
         case VMOBJDVariable.MainTreeID:
             return (short)objd.BHAV_MainID; // should this use OBJf functions?
         case VMOBJDVariable.GardeningTreeID:
             return (short)objd.BHAV_GardeningID;
         case VMOBJDVariable.TreeTableID:
             return (short)objd.TreeTableID;
         case VMOBJDVariable.IntersectionGroup:
             return (short)objd.InteractionGroupID;
         case VMOBJDVariable.Type:
             return (short)objd.ObjectType;
         case VMOBJDVariable.MasterID:
             return (short)objd.MasterID;
         case VMOBJDVariable.SubIndex:
             return (short)objd.SubIndex;
         case VMOBJDVariable.WashHandsTreeID:
             return (short)objd.BHAV_WashHandsID;
         case VMOBJDVariable.AnimTableID:
             return (short)objd.AnimationTableID;
         case VMOBJDVariable.GUID1:
             return (short)(objd.GUID % 0xFFFF);
         case VMOBJDVariable.GUID2:
             return (short)(objd.GUID >> 16);
         case VMOBJDVariable.Disabled:
             return (short)objd.Disabled;
         case VMOBJDVariable.PortalTreeID:
             throw new VMSimanticsException("Not Implemented!", context);
         case VMOBJDVariable.Price:
             return (short)objd.Price;
         case VMOBJDVariable.BodyStringsID:
             return (short)objd.BodyStringID;
         case VMOBJDVariable.SlotsID:
             return (short)objd.SlotID;
         case VMOBJDVariable.AllowIntersectionTreeID:
             return (short)objd.BHAV_AllowIntersectionID;
         case VMOBJDVariable.UsesFnTable:
             return (short)objd.UsesFnTable;
         case VMOBJDVariable.Bitfield1:
             return (short)objd.BitField1;
         case VMOBJDVariable.PrepareFoodTreeID:
             return (short)objd.BHAV_PrepareFoodID;
         case VMOBJDVariable.CookFoodTreeID:
             return (short)objd.BHAV_CookFoodID;
         case VMOBJDVariable.PlaceOnSurfaceTreeID:
             return (short)objd.BHAV_PlaceSurfaceID;
         case VMOBJDVariable.DisposeTreeID:
             return (short)objd.BHAV_DisposeID;
         case VMOBJDVariable.EatFoodTreeID:
             return (short)objd.BHAV_EatID;
         case VMOBJDVariable.PickupFromSlotTreeID:
             return (short)objd.BHAV_PickupID; //uh
         case VMOBJDVariable.WashDishTreeID:
             return (short)objd.BHAV_WashDishID;
         case VMOBJDVariable.EatingSurfaceTreeID:
             return (short)objd.BHAV_EatSurfaceID;
         case VMOBJDVariable.SitTreeID:
             return (short)objd.BHAV_SitID;
         case VMOBJDVariable.StandTreeID:
             return (short)objd.BHAV_StandID;
         case VMOBJDVariable.SalePrice:
             return (short)objd.SalePrice;
         case VMOBJDVariable.Unused35:
             throw new VMSimanticsException("Not Implemented!", context);
         case VMOBJDVariable.Unused36:
             throw new VMSimanticsException("Not Implemented!", context);
         case VMOBJDVariable.BrokenBaseGraphicOffset:
             throw new VMSimanticsException("Not Implemented!", context);
         case VMOBJDVariable.Unused38:
             throw new VMSimanticsException("Not Implemented!", context);
         case VMOBJDVariable.HasCriticalAttributes:
             throw new VMSimanticsException("Not Implemented!", context);
         case VMOBJDVariable.BuyModeType:
             return (short)objd.FunctionFlags;
         case VMOBJDVariable.CatalogStringsID:
             return (short)objd.CatalogStringsID;
         case VMOBJDVariable.IsGlobalSimObject:
             return (short)objd.Global;
         case VMOBJDVariable.InitTreeID:
             return (short)objd.BHAV_Init;
         case VMOBJDVariable.PlaceTreeID:
             return (short)objd.BHAV_Place;
         case VMOBJDVariable.UserPickupTreeID:
             return (short)objd.BHAV_UserPickup;
         case VMOBJDVariable.WallStyle:
             return (short)objd.WallStyle;
         case VMOBJDVariable.LoadTreeID:
             return (short)objd.BHAV_Load;
         case VMOBJDVariable.UserPlaceTreeID:
             return (short)objd.BHAV_UserPlace;
         case VMOBJDVariable.ObjectVersion:
             return (short)objd.ObjectVersion;
         case VMOBJDVariable.RoomChangedTreeID:
             return (short)objd.BHAV_RoomChange;
         case VMOBJDVariable.MotiveEffectsID:
             return (short)objd.MotiveEffectsID;
         case VMOBJDVariable.CleanupTreeID:
             return (short)objd.BHAV_Cleanup;
         case VMOBJDVariable.LevelInfoRequestTreeID:
             return (short)objd.BHAV_LevelInfo;
         case VMOBJDVariable.CatalogPopupID:
             return (short)objd.CatalogID;
         case VMOBJDVariable.ServingSurfaceTreeID:
             return (short)objd.CatalogID;
         case VMOBJDVariable.LevelOffset:
             return (short)objd.LevelOffset;
         case VMOBJDVariable.Shadow:
             return (short)objd.Shadow;
         case VMOBJDVariable.NumAttributes:
             return (short)objd.NumAttributes;
         case VMOBJDVariable.CleanTreeID:
             return (short)objd.BHAV_Clean;
         case VMOBJDVariable.QueueSkippedTreeID:
             return (short)objd.BHAV_QueueSkipped;
         case VMOBJDVariable.FrontDirection:
             return (short)objd.FrontDirection;
         case VMOBJDVariable.WallAdjacencyChangedTreeID:
             return (short)objd.BHAV_WallAdjacencyChanged;
         case VMOBJDVariable.MyLeadObject:
             return (short)objd.MyLeadObject;
         case VMOBJDVariable.DynamicSpritesBaseID:
             return (short)objd.DynamicSpriteBaseId;
         case VMOBJDVariable.NumDynamicSprites:
             return (short)objd.NumDynamicSprites;
         case VMOBJDVariable.ChairEntryFlags:
             return (short)objd.ChairEntryFlags;
         case VMOBJDVariable.TileWidth:
             return (short)objd.TileWidth;
         case VMOBJDVariable.LotCategories:
             return 0; //NOT IN OBJD RIGHT NOW!
         case VMOBJDVariable.BuildModeType:
             return (short)objd.BuildModeType;
         case VMOBJDVariable.OriginalGUID1:
             return (short)objd.OriginalGUID1;
         case VMOBJDVariable.OriginalGUID2:
             return (short)objd.OriginalGUID2;
         case VMOBJDVariable.SuitGUID1:
             return (short)objd.SuitGUID1;
         case VMOBJDVariable.SuitGUID2:
             return (short)objd.SuitGUID2;
         case VMOBJDVariable.PickupTreeID:
             return (short)objd.BHAV_Pickup;
         case VMOBJDVariable.ThumbnailGraphic:
             return (short)objd.ThumbnailGraphic;
         case VMOBJDVariable.ShadowFlags:
             return (short)objd.ShadowFlags;
         case VMOBJDVariable.FootprintMask:
             return (short)objd.FootprintMask;
         case VMOBJDVariable.DynamicMultiTileUpdateTreeID:
             return (short)objd.BHAV_DynamicMultiTileUpdate;
         case VMOBJDVariable.ShadowBrightness:
             return (short)objd.ShadowBrightness;
         case VMOBJDVariable.RepairTreeID:
             return (short)objd.BHAV_Repair;
         case VMOBJDVariable.WallStyleSpriteID:
             return (short)objd.WallStyleSpriteID;
         case VMOBJDVariable.RatingHunger:
             return (short)objd.RatingHunger;
         case VMOBJDVariable.RatingComfort:
             return (short)objd.CatalogID;
         case VMOBJDVariable.RatingHygiene:
             return (short)objd.RatingHygiene;
         case VMOBJDVariable.RatingBladder:
             return (short)objd.RatingBladder;
         case VMOBJDVariable.RatingEnergy:
             return (short)objd.RatingEnergy;
         case VMOBJDVariable.RatingFun:
             return (short)objd.RatingFun;
         case VMOBJDVariable.RatingRoom:
             return (short)objd.RatingRoom;
         case VMOBJDVariable.RatingSkillFlags:
             return (short)objd.RatingSkillFlags;
         case VMOBJDVariable.NumTypeAttributes:
             throw new VMSimanticsException("Not Implemented!", context); //??
         case VMOBJDVariable.MiscFlags:
             throw new VMSimanticsException("Not Implemented!", context); //??
         case VMOBJDVariable.TypeAttrGUID1:
             throw new VMSimanticsException("Not Implemented!", context);
         case VMOBJDVariable.TypeAttrGUID2:
             throw new VMSimanticsException("Not Implemented!", context);
         case VMOBJDVariable.InteractionResultStrings:
             throw new VMSimanticsException("Not Implemented!", context);
         case VMOBJDVariable.ClientHouseJoinTreeID:
             throw new VMSimanticsException("Not Implemented!", context);
         case VMOBJDVariable.PrepareForSaleTreeID:
             throw new VMSimanticsException("Not Implemented!", context);
         default:
             throw new VMSimanticsException("Unknown definition var", context);
     }
 }
Пример #3
0
        public OBJfFunctionEntry[] GenerateFunctionTable(OBJD obj)
        {
            OBJfFunctionEntry[] result = new OBJfFunctionEntry[33];

            result[0].ActionFunction = obj.BHAV_Init;
            result[1].ActionFunction = obj.BHAV_MainID;
            result[2].ActionFunction = obj.BHAV_Load;
            result[3].ActionFunction = obj.BHAV_Cleanup;
            result[4].ActionFunction = obj.BHAV_QueueSkipped;
            result[5].ActionFunction = obj.BHAV_AllowIntersectionID;
            result[6].ActionFunction = obj.BHAV_WallAdjacencyChanged;
            result[7].ActionFunction = obj.BHAV_RoomChange;
            result[8].ActionFunction = obj.BHAV_DynamicMultiTileUpdate;
            result[9].ActionFunction = obj.BHAV_Place;
            result[10].ActionFunction = obj.BHAV_PickupID;
            result[11].ActionFunction = obj.BHAV_UserPlace;
            result[12].ActionFunction = obj.BHAV_UserPickup;
            result[13].ActionFunction = obj.BHAV_LevelInfo;
            result[14].ActionFunction = obj.BHAV_ServingSurface;
            result[15].ActionFunction = obj.BHAV_Portal; //portal
            result[16].ActionFunction = obj.BHAV_GardeningID;
            result[17].ActionFunction = obj.BHAV_WashHandsID;
            result[18].ActionFunction = obj.BHAV_PrepareFoodID;
            result[19].ActionFunction = obj.BHAV_CookFoodID;
            result[20].ActionFunction = obj.BHAV_PlaceSurfaceID;
            result[21].ActionFunction = obj.BHAV_DisposeID;
            result[22].ActionFunction = obj.BHAV_EatID;
            result[23].ActionFunction = 0; //pickup from slot
            result[24].ActionFunction = obj.BHAV_WashDishID;
            result[25].ActionFunction = obj.BHAV_EatSurfaceID;
            result[26].ActionFunction = obj.BHAV_SitID;
            result[27].ActionFunction = obj.BHAV_StandID;
            result[28].ActionFunction = obj.BHAV_Clean;
            result[29].ActionFunction = 0; //repair
            result[30].ActionFunction = 0; //client house join
            result[31].ActionFunction = 0; //prepare for sale
            result[32].ActionFunction = 0; //house unload

            return result;
        }
Пример #4
0
        public virtual void Load(VMEntityMarshal input)
        {
            ObjectID = input.ObjectID;
            PersistID = input.PersistID;
            ObjectData = input.ObjectData;
            MyList = new LinkedList<short>(input.MyList);

            MainParam = input.MainParam; //parameters passed to main on creation.
            MainStackOBJ = input.MainStackOBJ;

            if (input.MasterGUID != 0)
            {
                var masterDef = FSO.Content.Content.Get().WorldObjects.Get(input.MasterGUID);
                MasterDefinition = masterDef.OBJ;
                UseTreeTableOf(masterDef);
            }
            else MasterDefinition = null;

            ContainerSlot = input.ContainerSlot;

            Attributes = input.Attributes;
            MeToObject = new Dictionary<ushort, List<short>>();
            foreach (var obj in input.MeToObject)  MeToObject[obj.Target] = new List<short>(obj.Values);

            DynamicSpriteFlags = input.DynamicSpriteFlags;
            Position = input.Position;
        }
Пример #5
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            var name = ChunkLabelEntry.Text;
            var guidT = GUIDEntry.Text;
            uint guid;
            var objProvider = Content.Content.Get().WorldObjects;
            if (name == "") MessageBox.Show("Name cannot be empty!", "Invalid Object Name");
            else if (guidT == "") MessageBox.Show("GUID cannot be empty!", "Invalid GUID");
            else if (!uint.TryParse(guidT, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out guid))
                MessageBox.Show("GUID is invalid! Make sure it is a hex string of size 8. (eg. 6789ABCD)", "Invalid GUID");
            else
            {
                lock (objProvider.Entries)
                {
                    if (objProvider.Entries.ContainsKey(guid))
                    {
                        MessageBox.Show("This GUID is already being used!", "GUID is Taken!");
                        return;
                    }

                    //OK, it's valid. Now to add it to the objects system...
                    //This is a little tricky because we want to add an object that does not exist yet.
                    //There's a special function just for this! But first, we need an OBJD...

                    var obj = new OBJD()
                    {
                        GUID = guid,
                        ObjectType = OBJDType.Normal,
                        ChunkLabel = name,
                        ChunkID = 1,
                        ChunkProcessed = true,
                        ChunkType = "OBJD",
                        ChunkParent = TargetIff,
                        AnimationTableID = 128
                    };

                    Content.Content.Get().Changes.BlockingResMod(new ResAction(() =>
                    {
                        //find a free space to place the object
                        ushort id = 16807; //todo: why???
                        var list = TargetIff.List<OBJD>();
                        if (list != null)
                        {
                            foreach (var chk in list.OrderBy(x => x.ChunkID))
                            {
                                if (chk.ChunkID == id)
                                    id++;
                            }
                        }
                        obj.ChunkID = id;
                        //add it to the iff file
                        TargetIff.AddChunk(obj);
                    }, obj));

                    if (IsNew)
                    {
                        //add a default animation table, for quality of life reasons

                        var anim = new STR()
                        {
                            ChunkLabel = name,
                            ChunkID = 128,
                            ChunkProcessed = true,
                            ChunkType = "STR#",
                            ChunkParent = TargetIff,
                        };

                        anim.InsertString(0, new STRItem { Value = "", Comment = "" });
                        TargetIff.AddChunk(anim);

                        var filename = TargetIff.RuntimeInfo.Path;
                        Directory.CreateDirectory(Path.GetDirectoryName(filename));
                        using (var stream = new FileStream(filename, FileMode.Create))
                            TargetIff.Write(stream);
                    }

                    //add it to the provider
                    objProvider.AddObject(TargetIff, obj);

                    DialogResult = DialogResult.OK;
                    ResultGUID = guid;
                    Close();
                }
            }
        }