Exemple #1
0
        private static void OnStatActionMessage(long entityId, Dictionary <string, MyStatLogic.MyStatAction> statActions)
        {
            MyEntity entity = null;

            if (!MyEntities.TryGetEntityById(entityId, out entity))
            {
                return;
            }

            MyEntityStatComponent statComponent = null;

            if (!entity.Components.TryGet <MyEntityStatComponent>(out statComponent))
            {
                return;
            }

            MyStatLogic script = new MyStatLogic();

            script.Init(entity as IMyCharacter, statComponent.m_stats, "LocalStatActionScript");
            foreach (var actionPair in statActions)
            {
                script.AddAction(actionPair.Key, actionPair.Value);
            }

            statComponent.m_scripts.Add(script);
        }
        private static void OnStatActionMessage(ref StatActionMsg msg, MyNetworkClient sender)
        {
            if (msg.StatActions == null)
            {
                return;
            }

            MyEntity entity = null;

            if (!MyEntities.TryGetEntityById(msg.EntityId, out entity))
            {
                return;
            }

            MyEntityStatComponent statComponent = null;

            if (!entity.Components.TryGet <MyEntityStatComponent>(out statComponent))
            {
                return;
            }

            MyStatLogic script = new MyStatLogic();

            script.Init(entity as IMyCharacter, statComponent.m_stats, "LocalStatActionScript");
            foreach (var actionPair in msg.StatActions)
            {
                script.AddAction(actionPair.Key, actionPair.Value);
            }

            statComponent.m_scripts.Add(script);
        }
Exemple #3
0
        private static void OnStatActionMessage(long entityId, Dictionary <string, MyStatLogic.MyStatAction> statActions)
        {
            MyEntity entity = null;

            if (MyEntities.TryGetEntityById(entityId, out entity, false))
            {
                MyEntityStatComponent component = null;
                if (entity.Components.TryGet <MyEntityStatComponent>(out component))
                {
                    MyStatLogic item = new MyStatLogic();
                    item.Init(entity as IMyCharacter, component.m_stats, "LocalStatActionScript");
                    foreach (KeyValuePair <string, MyStatLogic.MyStatAction> pair in statActions)
                    {
                        item.AddAction(pair.Key, pair.Value);
                    }
                    component.m_scripts.Add(item);
                }
            }
        }
Exemple #4
0
 private void InitScript(string scriptName)
 {
     if (scriptName == "SpaceStatEffect")
     {
         MySpaceStatEffect item = new MySpaceStatEffect();
         item.Init(base.Entity as IMyCharacter, this.m_stats, "SpaceStatEffect");
         this.m_scripts.Add(item);
     }
     else
     {
         Type type;
         if (MyScriptManager.Static.StatScripts.TryGetValue(scriptName, out type))
         {
             MyStatLogic item = (MyStatLogic)Activator.CreateInstance(type);
             if (item != null)
             {
                 item.Init(base.Entity as IMyCharacter, this.m_stats, scriptName);
                 this.m_scripts.Add(item);
             }
         }
     }
 }
		private static void OnStatActionMessage(ref StatActionMsg msg, MyNetworkClient sender)
		{
			if (msg.StatActions == null)
				return;

			MyEntity entity = null;
			if (!MyEntities.TryGetEntityById(msg.EntityId, out entity))
				return;

			MyEntityStatComponent statComponent = null;
			if (!entity.Components.TryGet<MyEntityStatComponent>(out statComponent))
				return;

			MyStatLogic script = new MyStatLogic();
			script.Init(entity as IMyCharacter, statComponent.m_stats, "LocalStatActionScript");
			foreach(var actionPair in msg.StatActions)
			{
				script.AddAction(actionPair.Key, actionPair.Value);
			}

			statComponent.m_scripts.Add(script);
		}
        private static void OnStatActionMessage(long entityId, Dictionary<string, MyStatLogic.MyStatAction> statActions)
		{
			MyEntity entity = null;
            if (!MyEntities.TryGetEntityById(entityId, out entity))
				return;

			MyEntityStatComponent statComponent = null;
			if (!entity.Components.TryGet<MyEntityStatComponent>(out statComponent))
				return;

			MyStatLogic script = new MyStatLogic();
			script.Init(entity as IMyCharacter, statComponent.m_stats, "LocalStatActionScript");
            foreach (var actionPair in statActions)
			{
				script.AddAction(actionPair.Key, actionPair.Value);
			}

			statComponent.m_scripts.Add(script);
		}