コード例 #1
0
ファイル: ObjectiveControl.cs プロジェクト: j1m1l0k0/server
        public ObjectiveControl()
        {
            EventHandlers["ocw:regObjSpace"] += new Action <int>(objSpace =>
            {
                m_objectiveSpace = VariableSpaceDispatcher.GetVariableSpace(objSpace);

                m_objectiveSpace.RegisterSetHandler("objective:", async(key, value) =>
                {
                    if (value.GetType() != typeof(bool))
                    {
                        Debug.WriteLine("created objective {0}", value.typeId);

                        TriggerEvent("ocw:newObjective", int.Parse(key.Split(':')[1]), value.typeId, value);
                    }
                    else
                    {
                        Objective instance;

                        if (m_instances.TryGetValue(int.Parse(key.Split(':')[1]), out instance))
                        {
                            await instance.TryDefuse();
                        }
                    }
                });
            });

            EventHandlers["ocw:newObjective"] += new Action <int, string, dynamic>(async(objectiveId, objectiveType, data) =>
            {
                var typeId = Assembly.GetExecutingAssembly().GetTypes().Where(a =>
                {
                    Debug.WriteLine("testing {0} {1}", a.Name, objectiveType);

                    return(a.Name.Equals(objectiveType, StringComparison.InvariantCultureIgnoreCase));
                }).Where(a => a.IsSubclassOf(typeof(Objective))).FirstOrDefault();

                if (typeId != null)
                {
                    Debug.WriteLine("Objective {0} resolved to {1}.", objectiveType, typeId.FullName);

                    var instance         = Activator.CreateInstance(typeId, data) as Objective;
                    instance.ObjectiveId = objectiveId;

                    if (instance != null)
                    {
                        instance.SetVariableSpace(VariableSpaceDispatcher.GetVariableSpace(data.spaceId));

                        await instance.Initialize();

                        BaseScript.RegisterScript(instance);

                        m_instances[objectiveId] = instance;
                    }
                }
                else
                {
                    Debug.WriteLine("couldn't resolve {0}", typeId);
                }
            });
        }
コード例 #2
0
        private static EventSink GetEventSink()
        {
            if (ms_eventSink == null)
            {
                ms_eventSink = new EventSink();
                BaseScript.RegisterScript(ms_eventSink);
            }

            return(ms_eventSink);
        }
コード例 #3
0
ファイル: MonitorInit.cs プロジェクト: drewomix/fivem-1
 public MonitorInit()
 {
     if (GetConvar("monitorMode", "false") == "true")
     {
         BaseScript.RegisterScript(new MonitorMain());
     }
     else
     {
         BaseScript.RegisterScript(new MonitorClient());
     }
 }
コード例 #4
0
        public BaseClient()
        {
            DataStore   = new GangWarDataStore();
            ZoneDisplay = new GangWarZoneDisplay(DataStore);
            Listener    = new GangWarListener(DataStore);

            BaseScript.RegisterScript(ZoneDisplay);
            BaseScript.RegisterScript(Listener);

            AddTextEntry("AMBIENT_GANG_LOST", "Enemy Gang: <C>Lost</C>");
            AddTextEntry("AMBIENT_GANG_MEXICAN", "Enemy Gang: <C>Vagos</C>");
            AddTextEntry("AMBIENT_GANG_FAMILY", "Enemy Gang: <C>Families</C>");

            EventHandlers["populationPedCreating"] += new Action <float, float, float, uint, dynamic>(PopulationPedCreating);
        }
コード例 #5
0
        public HttpServer()
        {
            m_ticker = new HttpServerScript();

            BaseScript.RegisterScript(m_ticker);
        }