Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Lab Assistant
Original Poster
#1 Old 27th Aug 2021 at 12:56 AM
Default cmomoney's ceilingFanMod
Hello!

I'm a bit ashamed to post here as I'm a total newbie in modding, but I'm trying to understand how it works by looking at others' mods, and I directly stumbled into a problem. I was studying cmomoney's Ceiling fan mod, I opened it in Visual Studio 2008, added the References and removed the mscorlib.dll as explained in the Creating a game compatible Visual Studio project, and I built a solution without editing a single space to cmomoney's code, and I got two errors "'Sims3.Gameplay.Interactions.InteractionInstance.InteractionDefinition.get': cannot explicitly call operator or accessor". Does it mean I haven't correctly set up Visual Studio? Because I really haven't changed anything to the code, and we all know it works perfectly, so the code can't be wrong and yet, VS doesn't want to build, so I'm already puzzled... (yeah, I'm easily impressed! )

cmomoney's code:
Code:
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.Interactions;
using Sims3.Gameplay.Objects.Lighting;
using Sims3.SimIFace;
using Sims3.UI;
using System;
namespace Sims3.Gameplay.Objects.CmoCeilingFan
{
	public class CeilingFan : LightFloorLamp
	{
		private sealed class OnOffFan : ImmediateInteraction<Sim, CeilingFan>
		{
			[DoesntRequireTuning]
			private sealed class Definition : InteractionDefinition<Sim, CeilingFan, CeilingFan.OnOffFan>
			{
				protected override string GetInteractionName(Sim a, CeilingFan target, InteractionObjectPair interaction)
				{
					if (!target.IsOn)
					{
						return "Turn On";
					}
					return "Turn Off";
				}
				public override string[] GetPath(bool isFemale)
				{
					return new string[]
					{
						"Fan"
					};
				}
				protected override bool Test(Sim a, CeilingFan target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
				{
					return !isAutonomous;
				}
			}
			public static readonly InteractionDefinition Singleton = new CeilingFan.OnOffFan.Definition();
			private string prompt = "Choose Fan Speed";
			private string button1 = "High";
			private string button2 = "Low";
			protected override bool Run()
			{
				InteractionDefinition arg_06_0 = base.get_InteractionDefinition();
				if (!this.Target.IsOn)
				{
					if (TwoButtonDialog.Show(this.prompt, this.button1, this.button2))
					{
						this.Target.TurnFanOn("SpinMed");
					}
					else
					{
						this.Target.TurnFanOn("SpinLow");
					}
					return true;
				}
				this.Target.TurnFanOff();
				return true;
			}
		}
		private sealed class SelectSpeed : ImmediateInteraction<Sim, CeilingFan>
		{
			[DoesntRequireTuning]
			private sealed class Definition : InteractionDefinition<Sim, CeilingFan, CeilingFan.SelectSpeed>
			{
				protected override string GetInteractionName(Sim a, CeilingFan target, InteractionObjectPair interaction)
				{
					return "Change Speed";
				}
				public override string[] GetPath(bool isFemale)
				{
					return new string[]
					{
						"Fan"
					};
				}
				protected override bool Test(Sim a, CeilingFan target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
				{
					return target.IsOn && !isAutonomous;
				}
			}
			public static readonly InteractionDefinition Singleton = new CeilingFan.SelectSpeed.Definition();
			private string prompt = "Choose Fan Speed";
			private string button1 = "High";
			private string button2 = "Low";
			protected override bool Run()
			{
				InteractionDefinition arg_06_0 = base.get_InteractionDefinition();
				if (TwoButtonDialog.Show(this.prompt, this.button1, this.button2))
				{
					this.Target.TurnFanOn("SpinMed");
				}
				else
				{
					this.Target.TurnFanOn("SpinLow");
				}
				return true;
			}
		}
		private bool IsOn;
		public override void OnStartup()
		{
			base.OnStartup();
			base.AddInteraction(CeilingFan.OnOffFan.Singleton);
			base.AddInteraction(CeilingFan.SelectSpeed.Singleton);
		}
		public bool TurnFanOn(string speed)
		{
			StateMachineClient stateMachineClient = StateMachineClient.Acquire(this, "CeilingFan");
			stateMachineClient.SetActor("CeilingFan", this);
			stateMachineClient.EnterState("CeilingFan", "Enter");
			stateMachineClient.RequestState("CeilingFan", speed);
			stateMachineClient.RequestState("CeilingFan", "Exit");
			this.IsOn = true;
			return true;
		}
		public bool TurnFanOff()
		{
			StateMachineClient stateMachineClient = StateMachineClient.Acquire(this, "CeilingFan");
			stateMachineClient.SetActor("CeilingFan", this);
			stateMachineClient.EnterState("CeilingFan", "Enter");
			stateMachineClient.RequestState("CeilingFan", "Stop");
			stateMachineClient.RequestState("CeilingFan", "Exit");
			this.IsOn = false;
			return true;
		}
	}
}


The "'Sims3.Gameplay.Interactions.InteractionInstance.InteractionDefinition.get': cannot explicitly call operator or accessor" error comes in line 43 & 87.
I'd be happy to understand what's happening!
Advertisement
Space Pony
#2 Old 27th Aug 2021 at 3:35 AM
You'll need to replace "get_InteractionDefinition()" with "InteractionDefinition". The code will then automatically access the get method of the property.

Did you copy this code from ILSpy? It seems very odd that it would have a direct call to the get method.

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had." - Eric Schmidt

If you enjoy the mods I put out, consider supporting me on patreon: www.patreon.com/Gamefreak130
Lab Assistant
Original Poster
#3 Old 27th Aug 2021 at 10:26 AM
Aw, thank you!
I opened the .dll with ILSpy, then save it as .csproj and opened it in Visual Studio 2008. That's weird, huh? Or did I make anything wrong here already?

Thanks to you, I'm going to exercise on this now, and make baby steps to see what happens if I change few changes to the code.
Lab Assistant
#4 Old 27th Aug 2021 at 3:46 PM
Decompilation is not perfect so you'll find yourself needing to change a few lines like this every now and then, but most of the time it's going to work fine.
Lab Assistant
Original Poster
#5 Old 27th Aug 2021 at 8:22 PM
Oh, I didn't know! I thought it would give the code exactly as it had been written, it's good to know it's not always the case. Thank you!
Back to top