Exemplo n.º 1
0
        private void InitVerb(Verb verb, VerbProperties properties, IVerbOwner owner, Tool tool, ManeuverDef maneuver, string id)
        {
            verb.loadID    = id;
            verb.verbProps = properties;
            verb.tool      = tool;
            verb.maneuver  = maneuver;
            CompEquippable                compEquippable                = this.directOwner as CompEquippable;
            Pawn                          pawn                          = this.directOwner as Pawn;
            HediffComp_VerbGiver          hediffComp_VerbGiver          = this.directOwner as HediffComp_VerbGiver;
            Pawn_MeleeVerbs_TerrainSource pawn_MeleeVerbs_TerrainSource = this.directOwner as Pawn_MeleeVerbs_TerrainSource;

            if (compEquippable != null)
            {
                verb.ownerEquipment = compEquippable.parent;
            }
            else if (pawn != null)
            {
                verb.caster = pawn;
            }
            else if (hediffComp_VerbGiver != null)
            {
                verb.ownerHediffComp = hediffComp_VerbGiver;
                verb.caster          = hediffComp_VerbGiver.Pawn;
            }
            else if (pawn_MeleeVerbs_TerrainSource != null)
            {
                verb.terrainDef = pawn_MeleeVerbs_TerrainSource.def;
                verb.caster     = pawn_MeleeVerbs_TerrainSource.parent.Pawn;
            }
            else
            {
                Log.ErrorOnce("Couldn't find verb source", 27797477, false);
            }
            if (verb.tool != null)
            {
                if (verb.ownerEquipment != null)
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Weapon;
                }
                else if (verb.ownerHediffComp != null)
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Hediff;
                }
                else if (verb.terrainDef != null)
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Terrain;
                }
                else
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Bodypart;
                }
            }
        }
Exemplo n.º 2
0
 public static string CalculateUniqueLoadID(IVerbOwner owner, Tool tool, ManeuverDef maneuver)
 {
     return(string.Format("{0}_{1}_{2}", owner.UniqueVerbOwnerID(), (tool == null) ? "NT" : tool.id, (maneuver == null) ? "NM" : maneuver.defName));
 }
Exemplo n.º 3
0
        private void InitVerbs(Func <Type, string, Verb> creator)
        {
            List <VerbProperties> verbProperties = this.directOwner.VerbProperties;

            if (verbProperties != null)
            {
                for (int i = 0; i < verbProperties.Count; i++)
                {
                    try
                    {
                        VerbProperties verbProperties2 = verbProperties[i];
                        string         text            = Verb.CalculateUniqueLoadID(this.directOwner, i);
                        this.InitVerb(creator(verbProperties2.verbClass, text), verbProperties2, this.directOwner, null, null, text);
                    }
                    catch (Exception ex)
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            "Could not instantiate Verb (directOwner=",
                            this.directOwner.ToStringSafe <IVerbOwner>(),
                            "): ",
                            ex
                        }), false);
                    }
                }
            }
            List <Tool> tools = this.directOwner.Tools;

            if (tools != null)
            {
                for (int j = 0; j < tools.Count; j++)
                {
                    Tool tool = tools[j];
                    foreach (ManeuverDef maneuverDef in from maneuver in DefDatabase <ManeuverDef> .AllDefsListForReading
                             where tool.capacities.Contains(maneuver.requiredCapacity)
                             select maneuver)
                    {
                        try
                        {
                            VerbProperties verb  = maneuverDef.verb;
                            string         text2 = Verb.CalculateUniqueLoadID(this.directOwner, tool, maneuverDef);
                            this.InitVerb(creator(verb.verbClass, text2), verb, this.directOwner, tool, maneuverDef, text2);
                        }
                        catch (Exception ex2)
                        {
                            Log.Error(string.Concat(new object[]
                            {
                                "Could not instantiate Verb (directOwner=",
                                this.directOwner.ToStringSafe <IVerbOwner>(),
                                "): ",
                                ex2
                            }), false);
                        }
                    }
                }
            }
            Pawn pawn = this.directOwner as Pawn;

            if (pawn != null && !pawn.def.tools.NullOrEmpty <Tool>())
            {
                for (int k = 0; k < pawn.def.tools.Count; k++)
                {
                    Tool tool = pawn.def.tools[k];
                    foreach (ManeuverDef maneuverDef2 in from maneuver in DefDatabase <ManeuverDef> .AllDefsListForReading
                             where tool.capacities.Contains(maneuver.requiredCapacity)
                             select maneuver)
                    {
                        try
                        {
                            VerbProperties verb2 = maneuverDef2.verb;
                            string         text3 = Verb.CalculateUniqueLoadID(this.directOwner, tool, maneuverDef2);
                            this.InitVerb(creator(verb2.verbClass, text3), verb2, this.directOwner, tool, maneuverDef2, text3);
                        }
                        catch (Exception ex3)
                        {
                            Log.Error(string.Concat(new object[]
                            {
                                "Could not instantiate Verb (directOwner=",
                                this.directOwner.ToStringSafe <IVerbOwner>(),
                                "): ",
                                ex3
                            }), false);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 public bool AdjustedEnsureLinkedBodyPartsGroupAlwaysUsable(Tool tool)
 {
     return(tool?.ensureLinkedBodyPartsGroupAlwaysUsable ?? ensureLinkedBodyPartsGroupAlwaysUsable);
 }
Exemplo n.º 5
0
 public VerbPropertiesWithSource(VerbProperties verbProps, Tool tool, ManeuverDef maneuver)
 {
     this.verbProps = verbProps;
     this.tool      = tool;
     this.maneuver  = maneuver;
 }
Exemplo n.º 6
0
 public VerbPropertiesWithSource(VerbProperties verbProps)
 {
     this.verbProps = verbProps;
     this.tool      = null;
     this.maneuver  = null;
 }
Exemplo n.º 7
0
        private void InitVerb(Verb verb, VerbProperties properties, IVerbOwner owner, Tool tool, ManeuverDef maneuver, string id)
        {
            verb.loadID    = id;
            verb.verbProps = properties;
            verb.tool      = tool;
            verb.maneuver  = maneuver;
            CompEquippable       compEquippable       = this.directOwner as CompEquippable;
            Pawn                 pawn                 = this.directOwner as Pawn;
            HediffComp_VerbGiver hediffComp_VerbGiver = this.directOwner as HediffComp_VerbGiver;

            if (compEquippable != null)
            {
                verb.ownerEquipment = compEquippable.parent;
            }
            else if (pawn != null)
            {
                verb.caster = pawn;
            }
            else if (hediffComp_VerbGiver != null)
            {
                verb.ownerHediffComp = hediffComp_VerbGiver;
                verb.caster          = hediffComp_VerbGiver.Pawn;
            }
            if (verb.tool != null)
            {
                if (verb.ownerEquipment != null)
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Weapon;
                }
                else if (verb.ownerHediffComp != null)
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Hediff;
                }
                else
                {
                    verb.implementOwnerType = ImplementOwnerTypeDefOf.Bodypart;
                }
            }
        }
Exemplo n.º 8
0
        private void InitVerbs(Func <Type, string, Verb> creator)
        {
            List <VerbProperties> verbProperties = this.directOwner.VerbProperties;

            if (verbProperties != null)
            {
                for (int i = 0; i < verbProperties.Count; i++)
                {
                    try
                    {
                        VerbProperties verbProperties2 = verbProperties[i];
                        string         text            = Verb.CalculateUniqueLoadID(this.directOwner, i);
                        this.InitVerb(creator(verbProperties2.verbClass, text), verbProperties2, this.directOwner, null, null, text);
                        if (verbProperties2.LaunchesProjectile && !verbProperties2.onlyManualCast)
                        {
                            VerbProperties verbProperties3 = verbProperties2.MemberwiseClone();
                            verbProperties3.defaultCooldownTime += verbProperties3.warmupTime;
                            verbProperties3.warmupTime           = 0f;
                            verbProperties3.meleeShoot           = true;
                            string text2 = Verb.CalculateUniqueLoadID(this.directOwner, -1 - i);
                            this.InitVerb(creator(verbProperties2.verbClass, text2), verbProperties2, this.directOwner, null, null, text2);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(string.Concat(new object[]
                        {
                            "Could not instantiate Verb (directOwner=",
                            this.directOwner.ToStringSafe <IVerbOwner>(),
                            "): ",
                            ex
                        }));
                    }
                }
            }
            List <Tool> tools = this.directOwner.Tools;

            if (tools != null)
            {
                for (int j = 0; j < tools.Count; j++)
                {
                    Tool tool = tools[j];
                    foreach (ManeuverDef current in from maneuver in DefDatabase <ManeuverDef> .AllDefsListForReading
                             where tool.capacities.Contains(maneuver.requiredCapacity)
                             select maneuver)
                    {
                        try
                        {
                            VerbProperties verb  = current.verb;
                            string         text3 = Verb.CalculateUniqueLoadID(this.directOwner, tool, current);
                            this.InitVerb(creator(verb.verbClass, text3), verb, this.directOwner, tool, current, text3);
                        }
                        catch (Exception ex2)
                        {
                            Log.Error(string.Concat(new object[]
                            {
                                "Could not instantiate Verb (directOwner=",
                                this.directOwner.ToStringSafe <IVerbOwner>(),
                                "): ",
                                ex2
                            }));
                        }
                    }
                }
            }
            Pawn pawn = this.directOwner as Pawn;

            if (pawn != null && !pawn.def.tools.NullOrEmpty <Tool>())
            {
                for (int k = 0; k < pawn.def.tools.Count; k++)
                {
                    Tool tool = pawn.def.tools[k];
                    foreach (ManeuverDef current2 in from maneuver in DefDatabase <ManeuverDef> .AllDefsListForReading
                             where tool.capacities.Contains(maneuver.requiredCapacity)
                             select maneuver)
                    {
                        try
                        {
                            VerbProperties verb2 = current2.verb;
                            string         text4 = Verb.CalculateUniqueLoadID(this.directOwner, tool, current2);
                            this.InitVerb(creator(verb2.verbClass, text4), verb2, this.directOwner, tool, current2, text4);
                        }
                        catch (Exception ex3)
                        {
                            Log.Error(string.Concat(new object[]
                            {
                                "Could not instantiate Verb (directOwner=",
                                this.directOwner.ToStringSafe <IVerbOwner>(),
                                "): ",
                                ex3
                            }));
                        }
                    }
                }
            }
        }