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
  #2  
Old 05-24-2012, 07:53 AM
FG28_Kodiak FG28_Kodiak is offline
Approved Member
 
Join Date: Dec 2009
Location: Swabia->Bavaria->Germany
Posts: 884
Default

Yes a Singleton Pattern in a DLL.
http://en.wikipedia.org/wiki/Singleton_pattern

Example Singleton (threadsafe)
Code:
   public sealed class Singleton
    {
        public int planeCount { get; set; }
        
        private static readonly Lazy<Singleton> lazy = new Lazy<Singleton>(() => new Singleton());

        public static Singleton GetInstance { get { return lazy.Value; } }

        private Singleton()
        { 
             // Initialisations
        }
    }
in Mis-C# you use for example

Code:
//$reference parts/core/MyDll.dll
using System;
using System.Collections.Generic;
using maddox.game;
using maddox.game.world;
using MyNameSpace;

public class Mission : AMission
{
  
    Singleton s=Singleton.GetInstance;  // get access to the singleton or create it if not exist.


 public override void OnPlaceEnter(Player player, AiActor actor, int placeIndex)
    {
        base.OnPlaceEnter(player, actor, placeIndex);

        s.planeCount += 1; // example
    }
}
use Singleton s=Singleton.GetInstance; in every Scriptfile you need acces to the singleton. There is always only one Singleton present.

Last edited by FG28_Kodiak; 05-24-2012 at 09:48 AM.
Reply With Quote
 

Thread Tools
Display Modes

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 05:33 PM.


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