Replies: 18 (Who?), Viewed: 500 times.
Lab Assistant
Original Poster
#1 Old 4th Oct 2020 at 5:54 PM
Default Problem with coding and definitions
So... As I think some of you know, I'm working on my second mod, basically something that would allow every occult type and sims from the Young Adult Age to the Adult to also use the canes from Generations. Battery has been of great help to me, and thanks to him, I'm on the last stages of development of this mod. It works basically by overwriting the interactions and code of the cane with versions that allow for Young Adults or Above to use them.
However, I ran into a certain problem. There's these two lines of code that give me errors:

Code:
this.mCane = this.Actor.GetActiveCane() ?? this.Actor.Inventory.Find<CyrusCane>();


Code:
this.mCane = this.Actor.GetActiveCane() ?? this.Actor.Inventory.Find<CyrusCane>();


Those, respectively, are lines 745 and and 152 from the code I've been developing. I have tried to use the mod without these lines, but the game just crashes when I try to purchase a cane from Buy Mode. I think the exact problem lies in the "GetActiveCane" thingie, that points to something in Sims3.Gameplay.Actors.Sim. How could I solve this problem?

To see the errors in context, here's the complete code:

Advertisement
Trainee Moderator
staff: trainee moderator
#2 Old 5th Oct 2020 at 2:57 PM
If you at the code for GetActiveCane, it actually returns a Cane object. And I think from what I understand of your project, you have actually made a new object CyrusCane:
Code:
 public Cane GetActiveCane()
{
    if (base.Inventory != null)
    {
        List<Cane> list = base.Inventory.FindAll<Cane>(checkInUse: false);
        foreach (Cane item in list)
        {
            if (item.UsingCane)
            {
                return item;
            }
        }
    }
    return null;
}
So I think the best thing to do, would be to create a new GetActiveCane() function that will do exactly the same thing, but instead of using Cane, it will use CyrusCane. So it will return a CyrusCane type instead of Cane, and it will look for CyrusCanes in the Inventory too. Hopefully the item.UsingCane will be fine, because your CyrusCane object should have inherited that from the Cane, though I could be wrong :P
Lab Assistant
Original Poster
#3 Old 5th Oct 2020 at 7:12 PM Last edited by CyrusBanefort : 5th Oct 2020 at 8:23 PM.
Quote:
Originally Posted by zoe22
If you at the code for GetActiveCane, it actually returns a Cane object. And I think from what I understand of your project, you have actually made a new object CyrusCane:
Code:
 public Cane GetActiveCane()
{
    if (base.Inventory != null)
    {
        List<Cane> list = base.Inventory.FindAll<Cane>(checkInUse: false);
        foreach (Cane item in list)
        {
            if (item.UsingCane)
            {
                return item;
            }
        }
    }
    return null;
}
So I think the best thing to do, would be to create a new GetActiveCane() function that will do exactly the same thing, but instead of using Cane, it will use CyrusCane. So it will return a CyrusCane type instead of Cane, and it will look for CyrusCanes in the Inventory too. Hopefully the item.UsingCane will be fine, because your CyrusCane object should have inherited that from the Cane, though I could be wrong :P


@zoe22 ,

That's what I'm trying to do currently. However, I'm also having problems with this. In a nutshell, what happens is that I paste the code, I get this error:

CS1061 'CyrusGetActiveCane' does not contain a definition for "Inventory" and no accessible extension method "Inventory" accepting a first argument of type 'CyrusGetActiveCane' could be found (are you missing a using directive or an assembly reference?)

When I try to use the entire thing's name found on IlSpy, I get this.

CS1061 'CyrusGetActiveCane' does not contain a definition for "Sims3" and no accessible extension method "Sims3" accepting a first argument of type 'CyrusGetActiveCane' could be found (are you missing a using directive or an assembly reference?)

Here's the original code:

Code:
public Cane GetActiveCane()
    {
      if (this.Inventory != null)
      {
        foreach (Cane cane in this.Inventory.FindAll<Cane>(false))
        {
          if (cane.UsingCane)
            return cane;
        }
      }
      return (Cane) null;
    }


And here's my code:

Code:
using System;
using System.Collections.Generic;
using System.Text;
using Sims3.Gameplay.Objects;
using Sims3.Gameplay.Abstracts;
using static Sims3.Gameplay.Abstracts.GameObject;
using Sims3.Gameplay;

namespace Cyrus.Sims3Game.CanesForEveryone
{
    public class CyrusGetActiveCane
    {
        public CyrusCane GetActiveCane()
        {
            if (this.Inventory != null)
            {
                foreach (Cane cane in this.Inventory.FindAll<Cane>(false))
                {
                    if (cane.UsingCane)
                        return cane;
                }
            }
            return (CyrusCane)null;
        }
    }
}


EDIT: I also tried to do the following:

Code:
namespace Cyrus.Sims3Game.CanesForEveryone
{
    public class CyrusGetActiveCane
    {
        public CyrusCane GetActiveCane()
        {
            if (GameObject.Inventory != null)
            {
                foreach (CyrusCane cane in this.Inventory.FindAll<CyrusCane>(false))
                {
                    if (cane.UsingCane)
                        return cane;
                }
            }
            return (CyrusCane)null;
        }
    }
}


But I get this error:

CS0120 An object reference is required for the non-static field "GameObject.Inventory", method, or property

EDIT 2: Ok, I managed to solve these new errors, but the original one persists even after I made this:

Code:
namespace Cyrus.Sims3Game.CanesForEveryone
{
    public class CyrusGetActiveCane : Sims3.Gameplay.Actors.Sim
    {
        public CyrusCane GetActiveCane()
        {
            if (this.Inventory != null)
            {
                foreach (CyrusCane cane in this.Inventory.FindAll<CyrusCane>(false))
                {
                    if (cane.UsingCane)
                        return cane;
                }
            }
            return (CyrusCane)null;
        }
    }
}
Trainee Moderator
staff: trainee moderator
#4 Old 5th Oct 2020 at 8:41 PM
The original GetActiveCane() I think is referring to the Actor sim when it uses this as in this.Inventory, so because your code doesn't have that info, you need to tell it that the Inventory you are looking through is the sim's. So you could use an argument in the function public CyrusCane GetActiveCane(Sim sim), and call it in Run() as GetActiveCane(Actor). Then use sim.Inventory etc in the function.

Also, the object that you are looking for and want to return is a CyrusCane so you'll need to use:
Code:
foreach (CyrusCane cane in this.Inventory.FindAll<CyrusCane>(false))
You could also just put the function in your CyrusCane class, rather than having a CyrusGetActiveCane class as well.

So you would have something like this:
Code:
//references
namespace Cyrus.Sims3Game.CanesForEveryone
{
   public class CyrusCane : Sims3.Gameplay.Objects.Cane
   {
      public CyrusCane GetActiveCane(Sim sim)
        {
            if (sim.Inventory != null)
            {
                foreach (CyrusCane cane in this.Inventory.FindAll<CyrusCane>(false))
                {
                    if (cane.UsingCane)
                        return cane;
                }
            }
            return null;
        }
   }
   //rest of CyrusCane code here...
}

Hope this works! 
edit: You might actually need the GetActiveCane class to be static, so it would be public static CyrusCane GetActiveCane(Sim sim). This is because it's not tied to any specific object, it just uses the Sim given and returns any cane that is being used by that sim. Originally the method was actually for the sim itself, which is why it used this.Inventory, as it was part of the Sim class itself.
Sorry if this is just confusing, honestly I don't always understand object oriented programming and static vs non static functions myself :P
But yeah, if you get an error saying it needs to be static, then you can just add that and hopefully it will be fine.
Lab Assistant
Original Poster
#5 Old 5th Oct 2020 at 9:30 PM
Quote:
Originally Posted by zoe22
The original GetActiveCane() I think is referring to the Actor sim when it uses this as in this.Inventory, so because your code doesn't have that info, you need to tell it that the Inventory you are looking through is the sim's. So you could use an argument in the function public CyrusCane GetActiveCane(Sim sim), and call it in Run() as GetActiveCane(Actor). Then use sim.Inventory etc in the function.

Also, the object that you are looking for and want to return is a CyrusCane so you'll need to use:
Code:
foreach (CyrusCane cane in this.Inventory.FindAll<CyrusCane>(false))
You could also just put the function in your CyrusCane class, rather than having a CyrusGetActiveCane class as well.

So you would have something like this:
Code:
//references
namespace Cyrus.Sims3Game.CanesForEveryone
{
   public class CyrusCane : Sims3.Gameplay.Objects.Cane
   {
      public CyrusCane GetActiveCane(Sim sim)
        {
            if (sim.Inventory != null)
            {
                foreach (CyrusCane cane in this.Inventory.FindAll<CyrusCane>(false))
                {
                    if (cane.UsingCane)
                        return cane;
                }
            }
            return null;
        }
   }
   //rest of CyrusCane code here...
}

Hope this works! 
edit: You might actually need the GetActiveCane class to be static, so it would be public static CyrusCane GetActiveCane(Sim sim). This is because it's not tied to any specific object, it just uses the Sim given and returns any cane that is being used by that sim. Originally the method was actually for the sim itself, which is why it used this.Inventory, as it was part of the Sim class itself.
Sorry if this is just confusing, honestly I don't always understand object oriented programming and static vs non static functions myself :P
But yeah, if you get an error saying it needs to be static, then you can just add that and hopefully it will be fine.


@zoe22 ,

Thank you very much for your help. How would the changed mCane thing look like? I admit, I'm very new to coding, and most of what I know comes from this site tutorials.
Trainee Moderator
staff: trainee moderator
#6 Old 6th Oct 2020 at 12:35 PM
Hmm I think you can leave the mCane as it is, as you have already defined it as a CyrusCane on line 115 here:
Code:
public CyrusCane mCane;
and 652 as well actually. So as long as when you are assigning something to it, what you are assigning is a CyrusCane rather than a Cane object, I think it should be fine.
Like you did here:
Code:
this.mCane = this.Actor.GetActiveCane() ?? this.Actor.Inventory.Find<CyrusCane>();
The reason I think it wasn't working is because originally this.Actor.GetActiveCane() would return a Cane rather than a CyrusCane, and so once you remake a GetActiveCane function that returns a CyrusCane, you won't have that problem. Though actually if the function is static, you won't need the this next to the GetActiveCane(). 

So you might want to word search and find all instances of "this.mCane = " and if there is a case where the thing that is being assigned to this.mCane is a Cane not a CyrusCane, change it to CyrusCane. it looks like it's just HoldingCanePosture that needs to be changed to have a CyrusCane argument rather than a Cane, so:
Code:
public HoldingCanePosture(Sim actor, CyrusCane cane, StateMachineClient smc)
...
And hopefully that will work :p

Though I am thinking if there is an easier way to do this, if you are wanting to completely replace the original cane object. You might be able to create custom versions of all the interactions, and in the definition just change Test() to return true for all types of sims you want. I think you also need to fill in the GetInteractionName function rather than just leaving it, otherwise you will get a blank name on the pie menu. I can't remember if you need to add in the Run() function too and just put base.Run() in it, or if you can leave it and it will do that automatically. But it might be worth a shot if it saves all the code of rewriting every Run() and having the custom object to take into account.

If you did want to try this, you would need to make custom interaction classes derived from the original.

Code:
public class CustomUseCane : UseCane
{
                public new static readonly InteractionDefinition Singleton = new Definition();
            
                public sealed new class Definition : InteractionDefinition<Sim, Cane, CustomUseCane>
                {
                    public override string GetInteractionName(Sim a, Cane target, InteractionObjectPair interaction)
                    {
                        return Localization.LocalizeString("...interaction name...");
                    }
                    public override bool Test(Sim a, Cane target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                    {
                        return true;
                    }
                }

         public override bool Run()
          {
           base.Run()
         }
  }

And use some pure modding to replace the original interactions OnPreLoad() 
with:
Code:
UseCane.Singleton = new UseCane.Definition();
That way, you'd just be using the original Cane object and using interactions with definitions that allow more sims to use the canes. And you don't need to mess around with so much code.
@Battery helped me with this for my plumbing mod

But of course it's up to you, especially as you have come so far with this way, and you might be close to having it work perfectly so *shrug*
Lab Assistant
DELETED POST
Original Poster
6th Oct 2020 at 3:06 PM
This message has been deleted by CyrusBanefort. Reason: error
Lab Assistant
Original Poster
#7 Old 6th Oct 2020 at 3:40 PM Last edited by CyrusBanefort : 6th Oct 2020 at 3:58 PM.
Quote:
Originally Posted by zoe22
Hmm I think you can leave the mCane as it is, as you have already defined it as a CyrusCane on line 115 here:
Code:
public CyrusCane mCane;
and 652 as well actually. So as long as when you are assigning something to it, what you are assigning is a CyrusCane rather than a Cane object, I think it should be fine.
Like you did here:
Code:
this.mCane = this.Actor.GetActiveCane() ?? this.Actor.Inventory.Find<CyrusCane>();
The reason I think it wasn't working is because originally this.Actor.GetActiveCane() would return a Cane rather than a CyrusCane, and so once you remake a GetActiveCane function that returns a CyrusCane, you won't have that problem. Though actually if the function is static, you won't need the this next to the GetActiveCane(). 

So you might want to word search and find all instances of "this.mCane = " and if there is a case where the thing that is being assigned to this.mCane is a Cane not a CyrusCane, change it to CyrusCane. it looks like it's just HoldingCanePosture that needs to be changed to have a CyrusCane argument rather than a Cane, so:
Code:
public HoldingCanePosture(Sim actor, CyrusCane cane, StateMachineClient smc)
...
And hopefully that will work :p

Though I am thinking if there is an easier way to do this, if you are wanting to completely replace the original cane object. You might be able to create custom versions of all the interactions, and in the definition just change Test() to return true for all types of sims you want. I think you also need to fill in the GetInteractionName function rather than just leaving it, otherwise you will get a blank name on the pie menu. I can't remember if you need to add in the Run() function too and just put base.Run() in it, or if you can leave it and it will do that automatically. But it might be worth a shot if it saves all the code of rewriting every Run() and having the custom object to take into account.

If you did want to try this, you would need to make custom interaction classes derived from the original.

Code:
public class CustomUseCane : UseCane
{
                public new static readonly InteractionDefinition Singleton = new Definition();
            
                public sealed new class Definition : InteractionDefinition<Sim, Cane, CustomUseCane>
                {
                    public override string GetInteractionName(Sim a, Cane target, InteractionObjectPair interaction)
                    {
                        return Localization.LocalizeString("...interaction name...");
                    }
                    public override bool Test(Sim a, Cane target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                    {
                        return true;
                    }
                }

         public override bool Run()
          {
           base.Run()
         }
  }

And use some pure modding to replace the original interactions OnPreLoad() 
with:
Code:
UseCane.Singleton = new UseCane.Definition();
That way, you'd just be using the original Cane object and using interactions with definitions that allow more sims to use the canes. And you don't need to mess around with so much code.
@Battery helped me with this for my plumbing mod

But of course it's up to you, especially as you have come so far with this way, and you might be close to having it work perfectly so *shrug*


@zoe22 ,

Yeah, my current problem is that the new GetActiveCane does not appear on VS suggestions - Just the original. I did try to simply replace the interactions im the initial phase of the mod, but errors were also abound.

EDIT: Also, when I try writing this

Code:
this.mCane = CyrusSim.GetActiveCane() ?? this.Actor.Inventory.Find<CyrusCane>();


CyrusSim being the class I put the GetActiveCane under, I get this error, even after turning the GetActiveCane static:

CS0120 C# An object reference is required for the "Sim.GetActiveCane()" non-static field, method, or property
Trainee Moderator
staff: trainee moderator
#8 Old 6th Oct 2020 at 4:05 PM
Hmm that's weird that it doesn't like it. You could call it something else and see if that works? Also, you will need to tell the GetActiveCane function what sim it is checking the cane for, so make sure to pass in the Actor sim in there 
Field Researcher
#9 Old 6th Oct 2020 at 5:14 PM
could you attach the *.cs file so that we can get an overview of your code ?


E: since you seem to have "working" code in addition to your codefile the package would be helpful
Lab Assistant
Original Poster
#10 Old 6th Oct 2020 at 5:15 PM Last edited by CyrusBanefort : 7th Oct 2020 at 2:46 AM.
@zoe22 ,
Ok, I managed to complete the code. Now, I'm trying to make it actually work in-game.
Basically, my method to replace the interactions and everything is to create a default replacement objk, referencing the CyrusCane class - But (I don't know if it is because of this, or the code, or something completely different) the game keeps crashing when I try to purchase a Llama Cane from Buy Mode. Any idea why? Do I need to create a entirely new object or something?

Here's the (hopefully) final version of the code:



EDIT: Oh wait, I solved it. It was the namespace, my bad for not seeing that part of the tutorial. So... I'm trying to have the interactions to appear, but I'm not managing to do it. What should I do? I even added this:

Code:
public override void OnStartup()
        {
            base.OnStartup();
            base.AddInteraction(UseCane.Singleton);
            base.AddInteraction(HarassEveryone.Singleton);
            base.AddInteraction(SetWalkStyle.Singleton);
            base.AddInteraction(StartUsingCane.Singleton);
            base.AddInteraction(StopUsingCane.Singleton);
        }


But the interactions still didn't appear.
Trainee Moderator
staff: trainee moderator
#11 Old 7th Oct 2020 at 11:59 AM
Ah yeah you will need the OnStartup method. After base.OnStartup() you will need to add RemoveAllInteractions(); to get rid of the original ones. You might want to leave it at that to see if all the interactions are being removed successfully before adding on your custom ones. 
When you say the interactions don't appear, what actually happens? When you hover over the cane, does it have the namespace like Sims3.Gameplay... ? If so, I think that means that the objk isn't right.
You could always try with a cloned cane to make sure it works before replacing the original, to make sure the problem is with the code and not the default replacement itself.

You probably just missed Battery's post, but maybe you could post the cs file and package ?
Lab Assistant
Original Poster
#12 Old 7th Oct 2020 at 3:52 PM
@zoe22 and @Battery ,

Yeah, I did miss Battery's post. My bad. Here's the link for the class and package:

https://mega.nz/folder/ycQE1bxJ#HIRMF1U68ajYV6ouz4AvRA
Field Researcher
#13 Old 7th Oct 2020 at 5:24 PM Last edited by Battery : 7th Oct 2020 at 5:37 PM.
Hey @CyrusBanefort,

i just took a look at your code public class CyrusSim : Sims3.Gameplay.Actors.Sim wont work as you intend since you are not creating a new type of sim that is used anywhere in game i would recommend just casting the original returntype and do a null check

E: and im not able to compile your code without errors
E2: you are not following the c# .net 2.0 spec, for instance you are using the nameof operator which is part of .net 4.0
Lab Assistant
Original Poster
#14 Old 7th Oct 2020 at 5:54 PM
@Battery ,

That about the nameof operator... That's interesting. I use two decompilers to open the game's dlls, one is IlSpy, to get the code most accurate to the original one, and DotPeek, to get the parts that won't compile with IlSpy. Is there something more that deviates from the net 2.0 spec in the code?
Field Researcher
#15 Old 7th Oct 2020 at 6:01 PM
Hmm ilspy should be fine for everything

what does not decompile correctly with it ?
Lab Assistant
Original Poster
#16 Old 7th Oct 2020 at 6:07 PM
Quote:
Originally Posted by Battery
Hmm ilspy should be fine for everything

what does not decompile correctly with it ?


@Battery ,

For example, I get those errors when opening the run() function of the TraitHarassWithCane class:

Code:
public override bool Run()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Expected O, but got Unknown
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Expected O, but got Unknown
		if (mHarassmentObject == null)
		{
			return false;
		}
		FindGoodLocationParams fglParams = default(FindGoodLocationParams);
		((FindGoodLocationParams)(ref fglParams))..ctor(mHarassmentObject.Position);
		fglParams.StartPosition = mHarassmentObject.Position;
		fglParams.RequiredRoomID = mHarassmentObject.RoomId;
		bool flag = false;
		if (GlobalFunctions.FindGoodLocation(Actor, fglParams, out Vector3 pos, out Vector3 _))
		{
			Route val = Actor.CreateRoute();
			val.PlanToPoint(pos);
			val.set_DoRouteFail(false);
			flag = Actor.DoRoute(val);
		}
		if (!flag)
		{
			Actor.RouteToDynamicObjectRadiusWithCondition(mHarassmentObject, kObjectFallbackRouteRadius[0], kObjectFallbackRouteRadius[1], null, null, (RouteOption)65536);
		}
		Actor.RouteTurnToFace(mHarassmentObject.Position);
		if (Actor.Posture is SwimmingInPool)
		{
			Actor.PlayRouteFailure();
			return false;
		}
		mCane = (Actor.GetActiveCane() ?? Actor.Inventory.Find<Cane>());
		if (mCane == null)
		{
			return false;
		}
		if (!mCane.UsingCane)
		{
			mCane.AddToUseList(Actor);
		}
		mCane.CreatePropCane();
		StandardEntry();
		BeginCommodityUpdates();
		EnterStateMachine("ElderCane", "Enter", "x");
		SetActor("Cane", (IHasScriptProxy)(object)mCane.PropCane);
		mCurrentStateMachine.AddOneShotStateEnteredEventHandler("Harass Everyone", (SacsEventHandler)(object)new SacsEventHandler(FadePropCaneIn));
		if (!(Actor.Posture is HoldingCanePosture))
		{
			mCurrentStateMachine.AddOneShotStateEnteredEventHandler("Exit", (SacsEventHandler)(object)new SacsEventHandler(FadePropCaneOut));
		}
		ThoughtBalloonManager.BalloonData balloonData = ThoughtBalloonManager.GetBalloonData(mIcon, Actor);
		balloonData.BalloonType = ThoughtBalloonTypes.kThoughtBalloon;
		balloonData.LowAxis = ThoughtBalloonAxis.kDislike;
		balloonData.Duration = ThoughtBalloonDuration.Short;
		Actor.ThoughtBalloonManager.ShowBalloon(balloonData);
		AnimateSim("Harass Everyone");
		AnimateSim("Exit");
		EndCommodityUpdates(succeeded: true);
		StandardExit();
		return true;
	}
Field Researcher
#17 Old 7th Oct 2020 at 6:12 PM
Hmm i think i have heared of that before but cant remember what remedys it did you load all references into ilspy ?
Lab Assistant
Original Poster
#18 Old 7th Oct 2020 at 6:27 PM
@Battery , yeah, looks like it was that. I loaded the other libraries in IlSpy and the problem was solved.
Test Subject
#19 Old 12th Oct 2020 at 1:22 PM
Quote:
Originally Posted by CyrusBanefort
@Battery ,

For example, I get those errors when opening the run() function of the TraitHarassWithCane class:

Code:
public override bool Run()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Expected O, but got Unknown
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Expected O, but got Unknown
		if (mHarassmentObject == null)
		{
			return false;
		}
		FindGoodLocationParams fglParams = default(FindGoodLocationParams);
		((FindGoodLocationParams)(ref fglParams))..ctor(mHarassmentObject.Position);
		fglParams.StartPosition = mHarassmentObject.Position;
		fglParams.RequiredRoomID = mHarassmentObject.RoomId;
		bool flag = false;
		if (GlobalFunctions.FindGoodLocation(Actor, fglParams, out Vector3 pos, out Vector3 _))
		{
			Route val = Actor.CreateRoute();
			val.PlanToPoint(pos);
			val.set_DoRouteFail(false);
			flag = Actor.DoRoute(val);
		}
		if (!flag)
		{
			Actor.RouteToDynamicObjectRadiusWithCondition(mHarassmentObject, kObjectFallbackRouteRadius[0], kObjectFallbackRouteRadius[1], null, null, (RouteOption)65536);
		}
		Actor.RouteTurnToFace(mHarassmentObject.Position);
		if (Actor.Posture is SwimmingInPool)
		{
			Actor.PlayRouteFailure();
			return false;
		}
		mCane = (Actor.GetActiveCane() ?? Actor.Inventory.Find<Cane>());
		if (mCane == null)
		{
			return false;
		}
		if (!mCane.UsingCane)
		{
			mCane.AddToUseList(Actor);
		}
		mCane.CreatePropCane();
		StandardEntry();
		BeginCommodityUpdates();
		EnterStateMachine("ElderCane", "Enter", "x");
		SetActor("Cane", (IHasScriptProxy)(object)mCane.PropCane);
		mCurrentStateMachine.AddOneShotStateEnteredEventHandler("Harass Everyone", (SacsEventHandler)(object)new SacsEventHandler(FadePropCaneIn));
		if (!(Actor.Posture is HoldingCanePosture))
		{
			mCurrentStateMachine.AddOneShotStateEnteredEventHandler("Exit", (SacsEventHandler)(object)new SacsEventHandler(FadePropCaneOut));
		}
		ThoughtBalloonManager.BalloonData balloonData = ThoughtBalloonManager.GetBalloonData(mIcon, Actor);
		balloonData.BalloonType = ThoughtBalloonTypes.kThoughtBalloon;
		balloonData.LowAxis = ThoughtBalloonAxis.kDislike;
		balloonData.Duration = ThoughtBalloonDuration.Short;
		Actor.ThoughtBalloonManager.ShowBalloon(balloonData);
		AnimateSim("Harass Everyone");
		AnimateSim("Exit");
		EndCommodityUpdates(succeeded: true);
		StandardExit();
		return true;
	}


Give a try to C# Decompiler Online. Usually it works for me.
Back to top