Ejemplo n.º 1
0
        public List <SimPersonality> GetClanMembership(SimDescription sim, bool includeLeadership)
        {
            List <SimPersonality> personalities = new List <SimPersonality>();

            if (sim != null)
            {
                if (includeLeadership)
                {
                    personalities.AddRange(GetClanLeadership(sim));
                }

                SimData simData = GetData(sim);

                List <string> clans = new List <string>(simData.Clans);
                foreach (string clan in clans)
                {
                    SimPersonality personality = GetPersonality(clan);
                    if (personality == null)
                    {
                        simData.RemoveClan(clan);
                    }
                    else
                    {
                        personalities.Add(personality);
                    }
                }
            }

            return(personalities);
        }
Ejemplo n.º 2
0
        public bool AllowAffair(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check)
        {
            if (!IsAffair(actor, target))
            {
                return(true);
            }

            if (OnAllowAffair == null)
            {
                return(false);
            }

            SimData actorData  = GetData(actor);
            SimData targetData = GetData(target);

            foreach (OnDualAllowFunc del in OnAllowAffair.GetInvocationList())
            {
                if (!del(stats, actorData, targetData, check))
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        protected override bool TargetAllow(SimDescription target)
        {
            if (!Romances.Allow(this, Sim, target))
            {
                return(false);
            }
            if (MarriageBaseScenario.TestForChildBlock(Sim, target))
            {
                IncStat("Child Are Married");
                return(false);
            }
            else
            {
                SimData targetData = GetData(target);

                if (targetData.HasAnyValue <ArrangedMarriageCasteOption, CasteOptions>())
                {
                    if (!targetData.Contains <ArrangedMarriageCasteOption>(GetData(Sim).Castes))
                    {
                        IncStat("Target Caste Fail");
                        return(false);
                    }
                }
            }

            return(base.TargetAllow(target));
        }
Ejemplo n.º 4
0
    public void setSubType(int subType, int focusItem)
    {
        AppEngine canvas   = AppEngine.getCanvas();
        SimData   simData  = canvas.getSimData();
        SimWorld  simWorld = canvas.getSimWorld();
        int       subType1 = this.m_subType;

        this.m_subType   = subType;
        this.m_focusItem = focusItem;
        switch (subType)
        {
        case -1:
            if (subType1 != -1)
            {
                this.resetSwiping(true);
            }
            this.m_focusItem = -1;
            break;

        case 10:
            this.m_titleId = simData.getSimName(focusItem);
            this.resetSwiping(false);
            break;

        case 11:
            this.m_titleId = simWorld.getItemDescString(focusItem);
            this.resetSwiping(false);
            break;
        }
    }
Ejemplo n.º 5
0
        public void TestNotifyDictRemoveCallback()
        {
            int            count        = 0;
            string         key          = null;
            dynamic        value        = -5;
            NotifyCallback mockDelegate = (string name, HAL_Value halValue) =>
            {
                count++;
                key   = name;
                value = halValue.GetBoolean();
            };

            SimData.ResetHALData(false);

            int uid = SimData.AnalogIn[0].RegisterVoltageCallback(mockDelegate, false);

            SimData.AnalogIn[0].SetVoltage(1.25);

            SimData.AnalogIn[0].CancelVoltageCallback(uid);

            SimData.AnalogIn[0].SetVoltage(13.84);

            Assert.AreEqual(1, count);
            Assert.AreEqual("Voltage", key);
            Assert.AreEqual(1.25, value);
        }
Ejemplo n.º 6
0
        public bool Allow(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check)
        {
            if ((check & AllowCheck.UserDirected) == AllowCheck.None)
            {
                if (Personalities.IsOpposing(stats, actor, target, true))
                {
                    stats.IncStat("Opposing Clan");
                    return(false);
                }
            }

            SimData actorData  = GetData(actor);
            SimData targetData = GetData(target);

            if (!actorData.Allowed <AllowCasteMoveOption>(targetData, true))
            {
                stats.IncStat("Caste Denied");
                return(false);
            }
            else if (actorData.Disallowed <DisallowCasteMoveOption>(targetData, true))
            {
                stats.IncStat("Caste Denied");
                return(false);
            }
            else if (!DualAllow(stats, actorData, targetData, check))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
            protected static bool OnDualAllow(Common.IStatGenerator stats, SimData actorData, SimData targetData, Managers.Manager.AllowCheck check)
            {
                ulong id = actorData.GetValue <ArrangedMarriageOption, ulong>();

                if (id != 0)
                {
                    if (targetData.SimDescription.SimDescriptionId != id)
                    {
                        stats.IncStat("Arranged");
                        return(false);
                    }
                }

                id = targetData.GetValue <ArrangedMarriageOption, ulong>();
                if (id != 0)
                {
                    if (actorData.SimDescription.SimDescriptionId != id)
                    {
                        stats.IncStat("Arranged");
                        return(false);
                    }
                }

                return(true);
            }
Ejemplo n.º 8
0
    public void InitTankFlocks(SimData simData)
    {
        int[] tankCounts = simData.GetTankCounts();
        int[,] tankSpecs = simData.GetTankSpecs();

        for (int side = 0; side < 2; side++)
        {
            int count = tankCounts[side];
            for (int i = 0; i < count; i++)
            {
                // put tank in flock
                int[]      specs   = { tankSpecs[side, 0], tankSpecs[side, 1], tankSpecs[side, 2] };
                GameObject newTank = tankFacotry.createTank(specs, simObserver, "Tank" + side + i);
                flocks[side].addTank(newTank);

                // place in position
                Vector3 newPosition = spawnPoints[side].position;
                newPosition.z += (i * 3);
                newTank.transform.position = newPosition;
            }
        }

        // add tank to gamemanager
        gameManager.SetCameraTargets(flocks, tankCounts);
    }
Ejemplo n.º 9
0
            protected static bool Test(IScoringGenerator stats, SimData actorData, SimData targetData, Managers.Manager.AllowCheck check)
            {
                SimDescription actor  = actorData.SimDescription;
                SimDescription target = targetData.SimDescription;

                if (actor.Partner != null)
                {
                    int chance = actorData.GetValue <ChanceOfAdulteryOption, int>();
                    if (chance == 0)
                    {
                        stats.IncStat("Adultery Denied");
                        return(false);
                    }
                    else if (stats.AddScoring("FlirtyPartner", chance, ScoringLookup.OptionType.Chance, actor) <= 0)
                    {
                        stats.IncStat("Adultery Scoring Fail");
                        return(false);
                    }

                    chance = targetData.GetValue <ChanceOfLiaisonOption, int>();
                    if (chance == 0)
                    {
                        stats.IncStat("Liaison Denied");
                        return(false);
                    }
                    if (stats.AddScoring("FlirtyPartner", chance, ScoringLookup.OptionType.Chance, target) <= 0)
                    {
                        stats.IncStat("Liaison Scoring Fail");
                        return(false);
                    }
                }

                return(true);
            }
Ejemplo n.º 10
0
    private bool isItemSelectable(int index)
    {
        if (!this.m_enabled)
        {
            return(false);
        }
        AppEngine canvas   = AppEngine.getCanvas();
        SimData   simData  = canvas.getSimData();
        SimWorld  simWorld = canvas.getSimWorld();

        switch (this.m_listId)
        {
        case 0:
        case 2:
        case 7:
        case 10:
        case 11:
        case 12:
        case 13:
            return(true);

        case 5:
            int inventoryNthItem = simData.getInventoryNthItem(index);
            return((simWorld.getItemFlags(inventoryNthItem) & 4) != 0);

        case 6:
            return(true);

        default:
            return(false);
        }
    }
Ejemplo n.º 11
0
        public bool AllowPartner(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check)
        {
            if (!Allow(stats, actor, check))
            {
                return(false);
            }
            if (!Allow(stats, target, check))
            {
                return(false);
            }

            SimData actorData  = GetData(actor);
            SimData targetData = GetData(target);

            if (!actorData.Allowed <AllowCasteRomanceOption>(targetData, true))
            {
                stats.IncStat("Caste Romance Denied");
                return(false);
            }
            else if (actorData.Disallowed <DisallowCasteRomanceOption>(targetData, true))
            {
                stats.IncStat("Caste Romance Denied");
                return(false);
            }
            else if (!DualAllow(stats, actorData, targetData, check))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 12
0
        public List <CasteOptions> GetMatching(SimDescription sim, int netWorth)
        {
            List <CasteOptions> results = new List <CasteOptions>();

            SimData simData = GetData(sim);

            if (simData.GetValue <AllowCasteOption, bool>())
            {
                List <ulong> manualCastes = simData.GetValue <ManualCasteOption, List <ulong> >();

                foreach (CasteOptions caste in Options.AllCastes)
                {
                    if (manualCastes.Contains(caste.ID))
                    {
                        results.Add(caste);
                    }
                    else if (caste.GetValue <CasteAutoOption, bool>())
                    {
                        if (caste.Matches(sim, netWorth))
                        {
                            results.Add(caste);
                        }
                    }
                }

                results.Sort(CasteOptions.SortByPriority);
            }

            // aye, adding another simData check here seems to cause this to explode...

            return(results);
        }
Ejemplo n.º 13
0
        protected virtual void GetPotentialSkills(List <SkillNames> skills)
        {
            SimData data = Options.GetSim(Sim);

            Career career = Sim.Occupation as Career;

            if (career != null)
            {
                foreach (PerfMetric metric in career.CurLevel.Metrics)
                {
                    MetricSkillX skillMetric = metric as MetricSkillX;
                    if (skillMetric == null)
                    {
                        continue;
                    }

                    Skill skill = Sim.SkillManager.GetSkill <Skill>(skillMetric.SkillGuid);
                    if (skill != null)
                    {
                        if (skill.ReachedMaxLevel())
                        {
                            continue;
                        }
                    }

                    if (!Skills.AllowSkill(this, Sim, data, skillMetric.SkillGuid))
                    {
                        continue;
                    }

                    skills.Add(skillMetric.SkillGuid);
                }
            }

            if (skills.Count == 0)
            {
                if (RandomUtil.RandomChance(AddScoring("GeneralSkilling", Sim)))
                {
                    foreach (Skill staticSkill in SkillManager.SkillDictionary)
                    {
                        Skill skill = Sim.SkillManager.GetSkill <Skill>(staticSkill.Guid);
                        if (skill != null)
                        {
                            if (skill.ReachedMaxLevel())
                            {
                                continue;
                            }
                        }

                        if (!Skills.AllowSkill(this, Sim, data, staticSkill.Guid))
                        {
                            continue;
                        }

                        skills.Add(staticSkill.Guid);
                    }
                }
            }
        }
Ejemplo n.º 14
0
 public void TestCreatePDPUpperLimit()
 {
     SimData.ResetHALData(false);
     Assert.Throws <ArgumentOutOfRangeException>(() =>
     {
         PowerDistributionPanel pdp = new PowerDistributionPanel(PDPModules);
         pdp.GetCurrent(0);
     });
 }
Ejemplo n.º 15
0
        protected override void PrivatePerform(SimDescription sim, SimData data, ScenarioFrame frame)
        {
            PregnancySimData other = data.Get <PregnancySimData>();

            if (sim.IsPregnant)
            {
                if ((other.mLastCheckPregnancy != 0) && (other.mLastCheckPregnancy < SimClock.ElapsedCalendarDays()))
                {
                    if (!AllowProgression(sim))
                    {
                        // Delay pregnancy indefinitely
                        sim.Pregnancy.mHourOfPregnancy = other.mPregnancyHour;

                        IncStat("Pregnancy Suspended");
                    }
                    else
                    {
                        if (other.mPregnancyHour == sim.Pregnancy.mHourOfPregnancy)
                        {
                            IncStat(sim.FirstName + " " + sim.LastName + ": Stuck Pregnancy", Common.DebugLevel.High);

                            if (!SimTypes.IsSelectable(sim))
                            {
                                Sims.Reset(sim);

                                if ((sim.CreatedSim != null) && (sim.LotHome != null))
                                {
                                    SimDescription dad = ManagerSim.Find(sim.Pregnancy.DadDescriptionId);
                                    if (dad != null)
                                    {
                                        Sims.Instantiate(dad, sim.LotHome, false);
                                    }

                                    if (sim.Pregnancy.PreggersAlarm != AlarmHandle.kInvalidHandle)
                                    {
                                        AlarmManager.Global.RemoveAlarm(sim.Pregnancy.PreggersAlarm);
                                        sim.Pregnancy.PreggersAlarm = AlarmHandle.kInvalidHandle;
                                    }
                                    sim.Pregnancy.Continue(sim.CreatedSim, true);

                                    IncStat("Pregnancy Reset");
                                }
                            }
                        }
                    }
                }

                other.mPregnancyHour      = sim.Pregnancy.mHourOfPregnancy;
                other.mLastCheckPregnancy = SimClock.ElapsedCalendarDays();
            }
            else
            {
                other.mPregnancyHour      = 0;
                other.mLastCheckPregnancy = 0;
            }
        }
Ejemplo n.º 16
0
    public override void processInput(int _event, int[] args)
    {
        SimData simData = AppEngine.getCanvas().getSimData();

        if (this.m_state != 0)
        {
            return;
        }
        base.processInput(_event, args);
        switch (this.m_type)
        {
        case 0:
            if (this.m_subType == -1)
            {
                if (!Scene.checkCommand(_event, args, int.MinValue))
                {
                    break;
                }
                int index = args[2];
                this.setSubType(10, simData.getRelationshipNthItem(index));
                break;
            }
            if (!Scene.checkCommand(_event, args, 1048576))
            {
                break;
            }
            this.setType(this.m_type);
            break;

        case 3:
            if (!Scene.checkCommand(_event, args, 16384))
            {
                break;
            }
            simData.dreamToPromise();
            break;

        case 6:
            if (this.m_subType == -1)
            {
                if (!Scene.checkCommand(_event, args, int.MinValue))
                {
                    break;
                }
                int index = args[2];
                this.setSubType(11, simData.getInventoryNthItem(index));
                break;
            }
            if (!Scene.checkCommand(_event, args, 1048576))
            {
                break;
            }
            this.setType(this.m_type);
            break;
        }
    }
Ejemplo n.º 17
0
    public void Start()
    {
        // default simdata
        data = new SimData();
        data.SetTankCount(1, 0);
        data.SetTankCount(1, 1);
        data.SetTankSpecs(new int[] { 1, 1, 1 }, 0);
        data.SetTankSpecs(new int[] { 1, 1, 1 }, 1);

        started = false;
    }
Ejemplo n.º 18
0
    public Dictionary <string, int> FruitPrepTime;  // FruitTyp and Timer

    void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
            return;
        }

        _instance = this;
        DontDestroyOnLoad(this.gameObject);
    }
Ejemplo n.º 19
0
 public bool AllowSkill(Common.IStatGenerator stats, SimDescription sim, SimData settings, SkillNames skill)
 {
     if (OnAllowSkill != null)
     {
         return(OnAllowSkill(stats, settings, skill));
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 20
0
            protected static bool OnAllowAffair(IScoringGenerator stats, SimData actorData, SimData targetData, Managers.Manager.AllowCheck check)
            {
                if (!Test(stats, actorData, targetData, check))
                {
                    return(false);
                }

                if (!Test(stats, targetData, actorData, check))
                {
                    return(false);
                }

                return(true);
            }
Ejemplo n.º 21
0
        protected static bool OnPrivateAllow(Common.IStatGenerator stats, SimData settings, Managers.Manager.AllowCheck check)
        {
            if (!settings.GetValue <AllowSkillOption, bool>())
            {
                stats.IncStat("Allow: Skills Denied");
                return(false);
            }
            else if (!settings.GetValue <AllowPushSkillOption, bool>())
            {
                stats.IncStat("Allow: Push Denied");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 22
0
        protected bool DualAllow(IScoringGenerator stats, SimData actorData, SimData targetData, AllowCheck check)
        {
            if (OnDualAllow != null)
            {
                foreach (OnDualAllowFunc del in OnDualAllow.GetInvocationList())
                {
                    if (!del(stats, actorData, targetData, check))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 23
0
        public void Perform(SimData data, ScenarioFrame frame)
        {
            if (data.SimDescription == null) return;

            IncStat(data.SimDescription.FullName, Common.DebugLevel.Logging);

            try
            {
                PrivatePerform(data.SimDescription, data, frame);
            }
            catch (Exception e)
            {
                Common.Exception(data.SimDescription, e);
            }
        }
Ejemplo n.º 24
0
    public void trackCASPreEdit()
    {
        SimData simData = AppEngine.getCanvas().getSimData();

        this.m_casHairType   = simData.getSimAttributeUnique(0, 2);
        this.m_casHairColor  = simData.getSimAttributeUnique(0, 3);
        this.m_casHeadType   = simData.getSimAttributeUnique(0, 11);
        this.m_casHeadColor  = simData.getSimAttributeUnique(0, 12);
        this.m_casTorsoType  = simData.getSimAttributeUnique(0, 5);
        this.m_casTorsoColor = simData.getSimAttributeUnique(0, 6);
        this.m_casLegsType   = simData.getSimAttributeUnique(0, 7);
        this.m_casLegsColor  = simData.getSimAttributeUnique(0, 8);
        this.m_casFeetType   = simData.getSimAttributeUnique(0, 9);
        this.m_casFeetColor  = simData.getSimAttributeUnique(0, 10);
    }
Ejemplo n.º 25
0
        protected override ICollection <SimDescription> GetTargets(SimDescription sim)
        {
            SimData simData = GetData(sim);

            List <SimDescription> results = new List <SimDescription>();

            foreach (SimDescription target in Sims.TeensAndAdults)
            {
                if (simData.Contains <ArrangedMarriageCasteOption>(GetData(target).Castes))
                {
                    results.Add(target);
                }
            }

            return(results);
        }
Ejemplo n.º 26
0
        public bool Allow(IScoringGenerator stats, SimDescription actor, SimDescription target, AllowCheck check)
        {
            if (!Allow(stats, actor, check))
            {
                return(false);
            }

            if (!Allow(stats, target, check))
            {
                return(false);
            }

            if (!Flirts.CanHaveAutonomousRomance(stats, actor, target, ((check & AllowCheck.Active) == AllowCheck.Active)))
            {
                return(false);
            }

            SimData actorData  = GetData(actor);
            SimData targetData = GetData(target);

            if (!actorData.Allowed <AllowCasteCanBePregnantOption>(targetData, false))
            {
                stats.IncStat("Can Be Caste Denied");
                return(false);
            }
            else if (actorData.Disallowed <DisallowCasteCanBePregnantOption>(targetData, false))
            {
                stats.IncStat("Can Be Caste Denied");
                return(false);
            }
            else if (!actorData.Allowed <AllowCastePregnancyOption>(targetData, true))
            {
                stats.IncStat("Participation Caste Denied");
                return(false);
            }
            else if (actorData.Disallowed <DisallowCastePregnancyOption>(targetData, true))
            {
                stats.IncStat("Participation Caste Denied");
                return(false);
            }
            else if (!DualAllow(stats, actorData, targetData, check))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 27
0
            protected static bool OnAllow(Common.IStatGenerator stats, SimData sim, Managers.Manager.AllowCheck check)
            {
                SimDescription simDesc = sim.SimDescription;

                if (!sim.GetValue <AllowBreakupOption, bool>())
                {
                    stats.IncStat("Allow: Breakup Denied");
                    return(false);
                }
                else if (!StoryProgression.Main.GetValue <AllowBreakupOption, bool>(simDesc.Partner))
                {
                    stats.IncStat("Allow: Breakup Partner Denied");
                    return(false);
                }

                return(true);
            }
Ejemplo n.º 28
0
        public void TestNotifyDictAdditonNoInitialNotify()
        {
            int    count = 0;
            string key   = null;
            Action <dynamic, dynamic> mockDelegate = (k, v) =>
            {
                count++;
                key = k;
            };

            SimData.ResetHALData(false);

            //SimData.AnalogIn[0].Register("Voltage", mockDelegate);

            Assert.AreEqual(0, count);
            Assert.AreEqual(null, key);
        }
Ejemplo n.º 29
0
    public SimData GetSimData()
    {
        if (Session["currentSim"] != null)
        {
            SimFileData simData = (SimFileData)Session["currentSim"];
            SimData     sd      = new SimData();
            sd.SongTitle = simData.SongTitle;
            foreach (ChartData cd in from c in simData.Charts orderby c.ChartInfo.Style, c.ChartInfo.Difficulty select c)
            {
                sd.Charts.Add(cd.ChartInfo);
            }

            return(sd);
        }

        return(null);
    }
Ejemplo n.º 30
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Sim sim = Sim.CreatedSim;

            BandInstrument.PlayBandInstrument <TInstrument> interaction = sim.InteractionQueue.GetCurrentInteraction() as BandInstrument.PlayBandInstrument <TInstrument>;
            if (interaction != null)
            {
                int elapsedCalendarDays = SimClock.ElapsedCalendarDays();

                SimData data = GetData <SimData>(Sim);

                DateAndTime lastChange = data.mLast;
                lastChange.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);

                if (lastChange > SimClock.CurrentTime())
                {
                    data.mLast = SimClock.CurrentTime();

                    interaction.TriggerAudio(false);

                    if (interaction.mInstrumentSound == null)
                    {
                        Sims3.Gameplay.Skills.Guitar.Composition PlayingComposition = null;

                        try
                        {
                            PlayingComposition = (interaction.mSkill as BandSkill).GetRandomComposition(false);
                        }
                        catch (Exception)
                        {
                            // If the known compositions is zero, GetRandom will except
                        }

                        if (PlayingComposition != null)
                        {
                            interaction.mInstrumentSound = new ObjectSound(interaction.Target.ObjectId, PlayingComposition.AudioClip);
                            interaction.mInstrumentSound.StartLoop();
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 31
0
        protected static bool OnAllowSkill(Common.IStatGenerator stats, SimData settings, SkillNames skill)
        {
            if (settings.HasValue <DisallowSkillOption, SkillNames>(skill))
            {
                stats.IncStat("Allow: " + skill + " Denied");
                return(false);
            }
            else if (settings.GetValue <AllowOnlyExistingSkillOption, bool>())
            {
                if (settings.SimDescription.SkillManager.GetSkillLevel(skill) < 1)
                {
                    stats.IncStat("Allow: " + skill + " Only Existing Denied");
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 32
0
 protected abstract void PrivatePerform(SimDescription sim, SimData data, ScenarioFrame frame);