Jump to content
mcegla

[Help] Removing despawn logic from code-placed buildings.

1 post in this topic Last Reply

Highlighted Posts

Posted:
Last Online:  
 

Since pandemic started I found myself having too much time, so I returned to my master thesis mod to make it usable. I have basically rewritten all of it and now whole parsing is done with XML.LINQ in other process.

I’m trying to use it in game (not in map editor as before), but buildings placed by my code are not really cooperating with Plop The Growables, and No Abandonment mods.

Is there some simple way to disable zone check, abandoning etc. for those buildings on current patch? I want to keep buildings interactive (when placed in map editor, they will remain in one place, but will not have interactive popup windows, will not be “clickable” etc.).

Here’s simple code snippet that I use for buildings creation:

    public class BuildingFactory
    {
        private static int temp = 0;

        public void Create(Vector2 point, float angle, string BuildingType)
        {
            if (temp < BuildingManager.MAX_BUILDING_COUNT)
            {
                int length = 0;
                BuildingInfo building = PrefabCollection<BuildingInfo>.FindLoaded(BuildingType);
                if (building == null)
                {
                    Debug.LogError($"Building could not be found: {BuildingType}");
                }
                else
                {
                    SimulationManager.instance.AddAction(AddBuilding(point, angle, length, building));
                    temp++;
                    
                }
            }
            else
                Debug.Log($"MAX_BUILDING_COUNT reached");
        }

        private static IEnumerator AddBuilding(Vector2 point, float angle, int length, BuildingInfo building)
        {
            ushort buildingNum;
            var coordZ = Singleton<TerrainManager>.instance.SampleRawHeightSmoothWithWater(new Vector3(point.x, 0, point.y), false, 0f);
            BuildingManager.instance.CreateBuilding(out buildingNum, ref SimulationManager.instance.m_randomizer,
                building, new Vector3(point.x, coordZ, point.y), angle, length, Singleton<SimulationManager>.instance.m_currentBuildIndex);
            Singleton<SimulationManager>.instance.m_currentBuildIndex += 1u;
            yield return null;
        }
    }

And this is what I’m talking about:

CS.gif.e22d407f729b48c1a87208a42d645e9b.gif

Thanks:)

Share this post


Link to post
Share on other sites

Sign In or register to comment...

To comment in reply, you must be a community member

Sign In  

Already have an account? Sign in here.

Sign In Now

Create an Account  

Sign up to join our friendly community. It's easy!  

Register a New Account


×

Thank You for the Continued Support!

Simtropolis depends on donations to fund site maintenance costs.
Without your support, we just would not be in our 24th year online!  You really help make this a great community. *:thumb:

But we still need your support to stay online. If you're able to, please consider a donation to help us stay up and running. This helps sustain a platform where we can share our community creations for years to come.

Make a Donation, Get a Gift!

Expand your city with the best from the Simtropolis Exchange.
Make a Donation and get one or all three discs today!

STEX Collections

By way of a "Thank You" gift, we'd like to send you our STEX Collector's DVD. It's some of the best buildings, lots, maps and mods collected for you over the years. Check out the STEX Collections for more info.

Each donation helps keep Simtropolis online, open and free!

Thank you for reading and enjoy the site!

More About STEX Collections