示例#1
0
        public static void NotifySell(SimDescription sim, GameObject obj, int value)
        {
            try
            {
                obj.SoldFor(value);

                if (obj.CanBeSold())
                {
                    if (IsCollectable(obj))
                    {
                        foreach (SimDescription member in sim.Household.AllSimDescriptions)
                        {
                            Collecting skill = member.SkillManager.GetSkill <Collecting>(SkillNames.Collecting);
                            if (skill != null)
                            {
                                skill.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj.HasFlags(GameObject.FlagField.WasHarvested))
                    {
                        Gardening gardening = sim.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                        if (gardening != null)
                        {
                            gardening.HarvestableSold(value);
                        }
                        foreach (SimDescription member in sim.Household.AllSimDescriptions)
                        {
                            gardening = member.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                            if (gardening != null)
                            {
                                gardening.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj is INectarBottle)
                    {
                        INectarBottle bottle = obj as INectarBottle;

                        NectarSkill skill = sim.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar);
                        if (skill != null)
                        {
                            skill.SellNectarBottle(value);
                        }

                        if ((bottle.Creator != null) && (bottle.Creator.IsValid))
                        {
                            skill = bottle.Creator.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar);
                            if (skill != null)
                            {
                                skill.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj is IInvention)
                    {
                        IInvention invention = obj as IInvention;

                        SimDescription inventor = invention.Inventor;

                        if ((inventor != null) && (inventor.IsValid))
                        {
                            InventingSkill skill2 = inventor.SkillManager.GetSkill <InventingSkill>(SkillNames.Inventing);
                            if (skill2 != null)
                            {
                                skill2.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj is IScubaCollectible)
                    {
                        ScubaDivingSkill skill3 = sim.SkillManager.AddElement(SkillNames.ScubaDiving) as ScubaDivingSkill;
                        if (skill3 != null)
                        {
                            skill3.SimoleonsFromSellingCollectibles += value;
                            skill3.UpdateXpForEarningMoney(value);
                        }
                    }

                    if (sim.CreatedSim != null)
                    {
                        obj.SendObjectSoldEvent(sim.CreatedSim);
                    }
                }
            }
            catch (Exception e)
            {
                Common.DebugException(sim.CreatedSim, obj, e);
            }
        }
示例#2
0
 public static void Research(IInvention invention) {
     invention.Add();
     instance.inventions.Remove(invention);
 }
示例#3
0
 public static bool TryMakeInvention(IInvention invention) {
     Int64[] counters = new Int64[(int)School.Type._Count];
     foreach(var c in invention.Costs) {
         counters[(int)c.Type] = c.Count;
     }
     if(CanSeeInvention(invention) && HasEnoughGeniuses(invention)) {
         foreach(var s in instance.currentSchools) {
             foreach(var q in s.Qualifications) {
                 if(counters[(int)q.SchoolType] != 0) {
                     if(s.NumberOfGeniusesInPool > counters[(int)q.SchoolType]) {
                         s.NumberOfGeniusesInPool -= counters[(int)q.SchoolType];
                         counters[(int)q.SchoolType] = 0;
                     } else if(s.NumberOfGeniusesInPool != 0) {
                         var count = s.NumberOfGeniusesInPool;
                         s.NumberOfGeniusesInPool = 0;
                         counters[(int)q.SchoolType] -= count;
                     }
                 }
             }
         }
     }
     foreach(var c in invention.Costs) {
         if(counters[(int)c.Type] != 0) {
             return false;
         }
     }
     return true;
 }
示例#4
0
    static bool HasEnoughGeniuses(IInvention invention) {
        Int64[] counters = new Int64[(int)School.Type._Count];

        foreach(var s in instance.currentSchools) {
            foreach(var q in s.Qualifications) {
                counters[(int)q.SchoolType] += s.NumberOfGeniusesInPool;
            }
        }

        foreach(var cost in invention.Costs) {
            if(counters[(int)cost.Type] < cost.Count) {
                return false;
            }
        }
        return true;
    }
示例#5
0
 public static bool CanSeeInvention(IInvention invention) {
     foreach(var cost in invention.Costs) {
         if(!FoundMatchingQualification(cost)) {
             return false;
         }
     }
     return true;
 }