Ejemplo n.º 1
0
        public static ObjectGuid CreateWrittenBookCallback(object customData, ref Simulator.ObjectInitParameters initData, Quality quality)
        {
            BookWrittenData bookWrittenData = customData as BookWrittenData;

            if (bookWrittenData == null)
            {
                return(ObjectGuid.InvalidObjectGuid);
            }
            ObjectGuid result;

            try
            {
                BookWritten bookWritten = GlobalFunctions.CreateObjectOutOfWorld("BookWritten") as BookWritten;
                if (bookWritten == null)
                {
                    result = ObjectGuid.InvalidObjectGuid;
                }
                else
                {
                    bookWritten = BookWritten.CreateOutOfWorld(bookWrittenData);
                    result      = bookWritten.ObjectId;
                }
            }
            catch (Exception ex)
            {
                StyledNotification.Show(new StyledNotification.Format("CreateWrittenBookCallback: " + ex.Message, StyledNotification.NotificationStyle.kGameMessagePositive));

                result = ObjectGuid.InvalidObjectGuid;
            }
            return(result);
        }
Ejemplo n.º 2
0
        public static ObjectGuid CreateBookWrittenCallback(object customData, ref Simulator.ObjectInitParameters initData, Quality quality)
        {
            BookWrittenData data = customData as BookWrittenData;

            if (data == null)
            {
                return(ObjectGuid.InvalidObjectGuid);
            }

            try
            {
                Notify(data.Title);

                BookWritten book = GlobalFunctions.CreateObjectOutOfWorld("BookWritten") as BookWritten;
                if (book == null)
                {
                    return(ObjectGuid.InvalidObjectGuid);
                }

                book.InitBookCommon(data);

                return(book.ObjectId);
            }
            catch (Exception e)
            {
                Common.Exception(data.ID, e);
                return(ObjectGuid.InvalidObjectGuid);
            }
        }
Ejemplo n.º 3
0
        public ObjectGuid CreateServingCallback(object customData, ref Simulator.ObjectInitParameters initData, Quality quality)
        {
            IFoodContainer container = (customData as Recipe).CreateFinishedFood(Recipe.MealQuantity.Group, Quality.Nice);

            if (container != null)
            {
                return(container.ObjectId);
            }

            return(ObjectGuid.InvalidObjectGuid);
        }
Ejemplo n.º 4
0
        public ObjectGuid CreateSnackCallback(object customData, ref Simulator.ObjectInitParameters initData, Quality quality)
        {
            Recipe recipe = (customData as Recipe);

            if (recipe != null)
            {
                IFoodContainer container = (customData as Recipe).CreateFinishedFood(Recipe.MealQuantity.Single, Quality.Outstanding);
                if (container != null)
                {
                    return(container.ObjectId);
                }
            }
            return(ObjectGuid.InvalidObjectGuid);
        }
Ejemplo n.º 5
0
        public override void OnStartup()
        {
            //Get ingredient data
            if (info.Type == ItemType.Ingredient)
            {
                Simulator.ObjectInitParameters objectInitParameters = Simulator.GetObjectInitParameters(base.ObjectId);
                bool trySetModelToDefault = objectInitParameters != null;
                IngredientInitParameters ingredientInitParameters = objectInitParameters as IngredientInitParameters;
                if (ingredientInitParameters != null)
                {
                    IngredientData ingredientData = ingredientInitParameters.IngredientData;
                    info.IngData       = ingredientData;
                    info.IngredientKey = ingredientData.Key;
                }
            }

            base.RemoveAllInteractions();
            base.AddInteraction(Restock.Singleton);
        }
Ejemplo n.º 6
0
        private static void CreateInventionAndAddToInventory(InventionData data, Sim Actor, bool isCheapToy, out GameObject invention)
        {
            Simulator.ObjectInitParameters initData = null;
            InventingSkill skill            = Actor.SkillManager.GetSkill <InventingSkill>(SkillNames.Inventing);
            bool           isImprovedWidget = false;

            if (data.InventType == InventionType.Widget)
            {
                Widget.Awesomeness standard = Widget.Awesomeness.Standard;
                if (skill.OppMasterInventorCompleted)
                {
                    standard = Widget.Awesomeness.Masterful;
                }
                else if (skill.OppWidgetWonderCompleted)
                {
                    standard = Widget.Awesomeness.Improved;
                }
                else
                {
                    float chance = 0f;
                    if (skill.SkillLevel >= InventionWorkbench.kLevelCanMakeImprovedWidget)
                    {
                        chance += InventionWorkbench.kChanceOfImprovedWidget;
                        if (Actor.HasTrait(TraitNames.Eccentric))
                        {
                            chance += InventionWorkbench.kChanceOfImprovedWidgetEccentric;
                        }
                        if (RandomUtil.RandomChance01(chance))
                        {
                            standard = Widget.Awesomeness.Improved;
                        }
                    }
                }
                isImprovedWidget = standard == Widget.Awesomeness.Improved;
                initData         = new WidgetInitParameters(standard, Actor.SimDescription, data.InventType, data.MedatorName);
            }

            if ((data.InventType == InventionType.Invention) || (data.InventType == InventionType.Toy))
            {
                initData = new CraftedToyInitParameters(skill.OppMasterInventorCompleted, Actor.SimDescription, data.InventType, isCheapToy);
            }

            invention = GlobalFunctions.CreateObject(data.MedatorName, data.ProdVersion, Vector3.OutOfWorld, 0x0, Vector3.UnitZ, null, initData) as GameObject;
            if (invention != null)
            {
                skill.RegisterInventionMade(data);
                if (data.PutInFamilyInventory)
                {
                    if (!Actor.Household.SharedFamilyInventory.Inventory.TryToAdd(invention))
                    {
                        invention.Destroy();
                        invention = null;
                    }
                }
                else if (!Inventories.TryToMove(invention, Actor))
                {
                    invention.Destroy();
                    invention = null;
                }
                if (invention != null)
                {
                    EventTracker.SendEvent(new CreatedInventionEvent(EventTypeId.kCreatedInvention, Actor, invention, data.InventType, isImprovedWidget));
                    if (data.InventType == InventionType.Widget)
                    {
                        EventTracker.SendEvent(EventTypeId.kInventorMadeWidget, Actor);
                    }
                    if (invention is TimeMachine)
                    {
                        EventTracker.SendEvent(EventTypeId.kInventorMadeTimeMachine, Actor);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public static IGameObject CreateObject(ulong instance, ProductVersion version, Simulator.ObjectInitParameters initData)
        {
            Hashtable overrides = new Hashtable(0x1);

            IGameObject obj = null;

            try
            {
                obj = CreateObjectWithOverrides(instance, version, Vector3.OutOfWorld, 0, Vector3.UnitZ, overrides, initData);

                if (obj is FailureObject)
                {
                    Common.DebugNotify((obj as FailureObject).mErrorText);
                }
            }
            catch (NullReferenceException exception)
            {
                string str = "Instance name was " + instance + Common.NewLine;
                throw new NullReferenceException(exception.Message + str);
            }
            return(obj);
        }
Ejemplo n.º 8
0
        private static IGameObject CreateObjectWithOverrides(ulong instance, ProductVersion version, Vector3 initPos, int level, Vector3 initFwd, Hashtable overrides, Simulator.ObjectInitParameters initData)
        {
            GlobalFunctions.FillInInitData(initPos, level, initFwd, ref initData);
            IGameObject createdObject = CreateObjectInternal(instance, version, overrides, initData);

            GlobalFunctions.CheckForFailure(createdObject, "Missing object resource instance " + instance + Common.NewLine);
            return(createdObject);
        }
Ejemplo n.º 9
0
        private static IGameObject CreateObjectInternal(ulong instance, ProductVersion version, Hashtable data, Simulator.ObjectInitParameters initData)
        {
            ResourceKey key = new ResourceKey(instance, 0x319e4f1d, ResourceUtils.ProductVersionToGroupId(version));

            return(GlobalFunctions.CreateObjectInternal(key, data, initData));
        }