Fulqrum Publishing Home   |   Register   |   Today Posts   |   Members   |   UserCP   |   Calendar   |   Search   |   FAQ

Go Back   Official Fulqrum Publishing forum > Fulqrum Publishing > IL-2 Sturmovik: Cliffs of Dover > FMB, Mission & Campaign builder Discussions

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #15  
Old 08-06-2012, 08:28 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

I use this to remove statics:
Code:
using System;
using System.Collections;
using System.Collections.Generic;
using maddox.GP;
using maddox.game;
using maddox.game.world;


public class Mission : AMission
{

    private static string userdocpath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
    private static string FILE_PATH = userdocpath + @"\1C SoftClub\il-2 sturmovik cliffs of dover\missions\Test\";
    private static string MISSION = FILE_PATH + "StaticTestSub.mis";

    Dictionary<GroundStationary, int> StationaryMisRelation = new Dictionary<GroundStationary, int>();



    public override void OnBattleStarted()
    {
        base.OnBattleStarted();

        MissionNumberListener = -1;
    }


    public override void OnMissionLoaded(int missionNumber)
    {
        base.OnMissionLoaded(missionNumber);

        GamePlay.gpLogServer(null, "OnMissionLoaded: {0}", new object[] { missionNumber });

        foreach (GroundStationary gs  in GamePlay.gpGroundStationarys())
        {
            if (!StationaryMisRelation.ContainsKey(gs))
                StationaryMisRelation[gs] = missionNumber;
        }
    }


    private void RemoveStationary(int missionNumber)
    {
        List<GroundStationary> KeysToRemove = new List<GroundStationary>();

        foreach (KeyValuePair<GroundStationary, int> kvp in StationaryMisRelation)
        {
            if (kvp.Value == missionNumber)
            {
                kvp.Key.Destroy();
                KeysToRemove.Add(kvp.Key);
            }
        }


        foreach (GroundStationary groundStationary in KeysToRemove)
        {
            StationaryMisRelation.Remove(groundStationary);
        }
        
    }

    public override void OnTrigger(int missionNumber, string shortName, bool active)
    {
        base.OnTrigger(missionNumber, shortName, active);

        if (shortName.Equals("MisLoad"))
        {
            GamePlay.gpLogServer(null, "MisLoad: {0}", new object[] { MISSION });
            GamePlay.gpPostMissionLoad(MISSION);
        }


        if (shortName.Equals("Trigger"))
        {
            
            foreach (KeyValuePair<GroundStationary, int> kvp in StationaryMisRelation)
            {
                GamePlay.gpLogServer(null, "Stationary: {0}; MissNr.: {1}", new object[] {kvp.Key.Title, kvp.Value});
            }
        }


        if (shortName.Equals("DeleteTrigger")) // from submission
        {
            GamePlay.gpLogServer(null, "DeleteTrigger MissionNr.: {0}", new object[] { missionNumber });

            RemoveStationary(missionNumber);
        }
    }

}
Explanation:
I store the GroundStationary with the missionNumber in a Dictionary. If a new (sub)mission is loaded i check in OnMissionLoaded if there are new Stationaries created if so i store them in the dictionary with their missionNumber.
If the submission triggers (in this example) the "DeleteTrigger" i remove all statics with this missionNumber.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:56 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2007 Fulqrum Publishing. All rights reserved.