コード例 #1
0
        private bool CheckAndGetLifeZone(Player p, Command cmd)
        {
            Life = null;

            World = null;

            Name = cmd.Next();

            if (String.IsNullOrWhiteSpace(Name))
            {
                p.Message("&WLife name is missing or empty");

                return(false);
            }

            World = p.World;

            if (World == null)
            {
                p.Message("&WYou are in limbo state. Prepare for eternal torment.");

                return(false);
            }

            lock (World.SyncRoot) {
                if (World.Map == null)
                {
                    return(false);
                }

                Life = World.GetLife(Name);

                return(true);
            }
        }
コード例 #2
0
 public bool TryAddLife(Life2DZone life)
 {
     if (null == life)
     {
         Logger.Log(LogType.Error, "trying to add null life instance");
         return(false);
     }
     lock (SyncRoot)
     {
         if (null == Map)
         {
             return(false);
         }
         if (map.LifeZones.ContainsKey(life.Name.ToLower()))
         {
             return(false);
         }
         map.LifeZones.Add(life.Name.ToLower(), life);
         if (!_physSchedulers[(int)TaskCategory.Life].Started)
         {
             _physSchedulers[(int)TaskCategory.Life].Start();
         }
     }
     return(true);
 }
コード例 #3
0
ファイル: LifeHandler.cs プロジェクト: fcraft-based/GemsCraft
        private static void SetAutoReset(Player p, Life2DZone life, string val)
        {
            AutoResetMethod method;

            val = val.ToLower();
            switch (val)
            {
            case "no":
            case "none":
                method = AutoResetMethod.None;
                break;

            case "toinitial":
            case "i":
                method = AutoResetMethod.ToInitial;
                break;

            case "torandom":
            case "r":
            case "rnd":
                method = AutoResetMethod.ToRandom;
                break;

            default:
                p.Message("&WUnrecognized auto reset method " + val + ".\n&h Type '/life help AutoReset' to see all the possible values.");
                return;
            }
            life.AutoReset = method;
            p.Message("&yAutoReset param set to " + Enum.GetName(typeof(AutoResetMethod), method));
        }
コード例 #4
0
        private static void SetAutoReset(Player p, Life2DZone life, string val)
        {
            AutoResetMethod method = AutoResetMethod.None;

            val = val.ToLower();

            if (val == "no" || val == "none")
            {
                method = AutoResetMethod.None;
            }
            else if (val == "toinitial" || val == "i")
            {
                method = AutoResetMethod.ToInitial;
            }
            else if (val == "torandom" || val == "r" || val == "rnd")
            {
                method = AutoResetMethod.ToRandom;
            }
            else
            {
                p.Message("&WUnrecognized auto reset method " + val + ".\n" +
                          "&hType '/life help AutoReset' to see all the possible values.");

                return;
            }

            life.AutoReset = method;

            p.Message("&yAutoReset param set to " + Enum.GetName(typeof(AutoResetMethod), method));
        }
コード例 #5
0
ファイル: LifeHandler.cs プロジェクト: fcraft-based/GemsCraft
 private void LifeCreateCallback(Player player, Vector3I[] marks, object state)
 {
     try
     {
         lock (_world.SyncRoot)
         {
             if (!CheckWorldPermissions(player))
             {
                 return;
             }
             if (null == _world.Map)
             {
                 return;
             }
             if (null != _world.GetLife(_name)) //check it again, since smone could create it in between
             {
                 player.Message("&WLife with such name exists already, choose another");
                 return;
             }
             Life2DZone life = new Life2DZone(_name, _world.Map, marks, player, (player.Info.Rank.NextRankUp ?? player.Info.Rank).Name);
             if (_world.TryAddLife(life))
             {
                 player.Message("&yLife was created. Named " + _name);
             }
             else
             {
                 player.Message("&WCoulnd't create life for some reason unknown."); //really unknown: we are under a lock so nobody could create a life with the same name in between
             }
         }
     }
     catch (Exception e)
     {
         player.Message("&WCreate life error: " + e.Message);
     }
 }
コード例 #6
0
ファイル: LifeHandler.cs プロジェクト: fcraft-based/GemsCraft
 private static void SetTorus(Player p, Life2DZone life, string val)
 {
     if (!bool.TryParse(val, out bool torus))
     {
         p.Message("&WExpected 'true' or 'false' as torus parameter value");
         return;
     }
     life.Torus = torus;
     p.Message("&yTorus param set to " + val);
 }
コード例 #7
0
ファイル: LifeHandler.cs プロジェクト: fcraft-based/GemsCraft
 private static void SetHalfDelay(Player p, Life2DZone life, string val)
 {
     if (!int.TryParse(val, out int delay) || delay < 0)
     {
         p.Message("&WExpected non-negative integer value as intermediate delay");
         return;
     }
     life.HalfStepDelay = delay;
     p.Message("&yIntermediate step delay set to " + val);
 }
コード例 #8
0
ファイル: LifeHandler.cs プロジェクト: fcraft-based/GemsCraft
 private static void SetDelay(Player p, Life2DZone life, string val)
 {
     if (!int.TryParse(val, out int delay) || delay <= 20)
     {
         p.Message("&WExpected integer value >=20 as delay");
         return;
     }
     life.Delay = delay;
     p.Message("&yStep delay set to " + val);
 }
コード例 #9
0
ファイル: LifeHandler.cs プロジェクト: fcraft-based/GemsCraft
        private static void SetNewborn(Player p, Life2DZone life, string val)
        {
            Block b = Map.GetBlockByName(val);

            if (b == Block.Undefined)
            {
                p.Message("&WUnrecognized block name " + val);
                return;
            }
            life.Newborn = b;
            p.Message("&yNewborn block set to " + val);
        }
コード例 #10
0
        private static void SetDead(Player p, Life2DZone life, string val)
        {
            Block block = Map.GetBlockByName(val);

            if (block == Block.Undefined)
            {
                p.Message("&WUnrecognized block name " + val);

                return;
            }

            life.Dead = block;

            p.Message("&yDead block set to " + val);
        }
コード例 #11
0
ファイル: LifeHandler.cs プロジェクト: fcraft-based/GemsCraft
        private static void OnPrint(Player p, Command cmd)
        {
            LifeHandler handler = GetCheckedLifeHandler(p, cmd);

            if (null == handler)
            {
                return;
            }
            Life2DZone l = handler._life;

            p.Message("&y" + l.Name + ": " + (l.Stopped ? "stopped" : "started") + ", delay " + l.Delay +
                      ", intermediate delay " + l.HalfStepDelay + ", is" + (l.Torus ? "" : " not") + " on torus, " +
                      "auto reset strategy is " + Enum.GetName(typeof(AutoResetMethod), l.AutoReset) +
                      ", owner is " + l.CreatorName +
                      ", changable by " + l.MinRankToChange +
                      ", block types: " + l.Normal + " is normal, " + l.Empty + " is empty, " + l.Dead + " is dead, " + l.Newborn + " is newborn");
        }
コード例 #12
0
 public Life2DZone GetLife(string name)
 {
     if (string.IsNullOrWhiteSpace(name))
     {
         Logger.Log(LogType.Error, "null or empty string in GetLife");
         return(null);
     }
     lock (SyncRoot)
     {
         if (null == Map)
         {
             return(null);
         }
         Life2DZone life = null;
         map.LifeZones.TryGetValue(name.ToLower(), out life);
         return(life);
     }
 }
コード例 #13
0
ファイル: LifeHandler.cs プロジェクト: Bedrok/800craft
 private static void SetTorus(Player p, Life2DZone life, string val)
 {
     bool torus;
     if (!bool.TryParse(val, out torus))
     {
         p.Message("&WExpected 'true' or 'false' as torus parameter value");
         return;
     }
     life.Torus = torus;
     p.Message("&yTorus param set to " + val);
 }
コード例 #14
0
ファイル: LifeHandler.cs プロジェクト: Bedrok/800craft
        private bool CheckAndGetLifeZone(Player p, Command cmd)
        {
            _life = null;
            _world = null;
            _name = cmd.Next();
            if (String.IsNullOrWhiteSpace(_name))
            {
                p.Message("&WLife name is missing or empty");
                return false;
            }

            _world = p.World;
            if (null == _world)
            {
                p.Message("&WYou are in limbo state. Prepare for eternal torment.");
                return false;
            }

            lock (_world.SyncRoot)
            {
                if (null == _world.Map)
                    return false;
                _life = _world.GetLife(_name);
                return true;
            }
        }
コード例 #15
0
ファイル: LifeHandler.cs プロジェクト: Bedrok/800craft
 private static void SetNormal(Player p, Life2DZone life, string val)
 {
     Block b = Map.GetBlockByName(val);
     if (b==Block.Undefined)
     {
         p.Message("&WUnrecognized block name "+val);
         return;
     }
     life.Normal = b;
     p.Message("&yNormal block set to " + val);
 }
コード例 #16
0
ファイル: LifeHandler.cs プロジェクト: Bedrok/800craft
 private static void SetHalfDelay(Player p, Life2DZone life, string val)
 {
     int delay;
     if (!int.TryParse(val, out delay) || delay < 0)
     {
         p.Message("&WExpected non-negative integer value as intermediate delay");
         return;
     }
     life.HalfStepDelay = delay;
     p.Message("&yIntermediate step delay set to " + val);
 }
コード例 #17
0
ファイル: LifeHandler.cs プロジェクト: Bedrok/800craft
 private static void SetDelay(Player p, Life2DZone life, string val)
 {
     int delay;
     if (!int.TryParse(val, out delay) || delay <=20)
     {
         p.Message("&WExpected integer value >=20 as delay");
         return;
     }
     life.Delay = delay;
     p.Message("&yStep delay set to "+val);
 }
コード例 #18
0
ファイル: LifeHandler.cs プロジェクト: Bedrok/800craft
 private static void SetAutoReset(Player p, Life2DZone life, string val)
 {
     AutoResetMethod method;
     val = val.ToLower();
     if (val == "no" || val == "none")
         method = AutoResetMethod.None;
     else if (val == "toinitial" || val == "i")
         method = AutoResetMethod.ToInitial;
     else if (val=="torandom" || val=="r" || val=="rnd")
         method = AutoResetMethod.ToRandom;
     else
     {
         p.Message("&WUnrecognized auto reset method "+val+".\n&h Type '/life help AutoReset' to see all the possible values.");
         return;
     }
     life.AutoReset = method;
     p.Message("&yAutoReset param set to " + Enum.GetName(typeof(AutoResetMethod), method));
 }
コード例 #19
0
ファイル: LifeHandler.cs プロジェクト: Bedrok/800craft
 private void LifeCreateCallback(Player player, Vector3I[] marks, object state)
 {
     try
     {
         lock (_world.SyncRoot)
         {
             if (!CheckWorldPermissions(player))
                 return;
             if (null == _world.Map)
                 return;
             if (null != _world.GetLife(_name)) //check it again, since smone could create it in between
             {
                 player.Message("&WLife with such name exists already, choose another");
                 return;
             }
             Life2DZone life = new Life2DZone(_name, _world, marks, player.Name, (player.Info.Rank.NextRankUp??player.Info.Rank).Name);
             if (_world.TryAddLife(life))
                 player.Message("&yLife was created. Named " + _name);
             else
                 player.Message("&WCoulnd't create life for some reason unknown."); //really unknown: we are under a lock so nobody could create a life with the same name in between
         }
     }
     catch (Exception e)
     {
         player.Message("&WCreate life error: " + e.Message);
     }
 }
コード例 #20
0
ファイル: World.cs プロジェクト: zINaPalm/LegendCraftSource
 public bool TryAddLife(Life2DZone life)
 {
     if (null==life)
     {
         Logger.Log(LogType.Error, "trying to add null life instance");
         return false;
     }
     lock (SyncRoot)
     {
         if (null==Map)
             return false;
         if (map.LifeZones.ContainsKey(life.Name.ToLower()))
             return false;
         map.LifeZones.Add(life.Name.ToLower(), life);
         if (!_physSchedulers[(int)TaskCategory.Life].Started)
             _physSchedulers[(int)TaskCategory.Life].Start();
     }
     return true;
 }
コード例 #21
0
ファイル: LifeHandler.cs プロジェクト: GlennMR/800craft
 private static void SetAutoReset( Player p, Life2DZone life, string val )
 {
     AutoResetMethod method;
     val = val.ToLower();
     switch (val)
     {
         case "none":
         case "no":
             method = AutoResetMethod.None;
             break;
         case "i":
         case "toinitial":
             method = AutoResetMethod.ToInitial;
             break;
         case "rnd":
         case "r":
         case "torandom":
             method = AutoResetMethod.ToRandom;
             break;
         default:
             p.Message( "&WUnrecognized auto reset method " + val + ".\n&h Type '/life help AutoReset' to see all the possible values." );
             return;
     }
     life.AutoReset = method;
     p.Message( "&yAutoReset param set to " + Enum.GetName( typeof( AutoResetMethod ), method ) );
 }