示例#1
0
            public override void StartLoading()
            {
                var user = plugin as IUser;

                if (user == null)
                {
                    throw new
                          ArgumentException($"provided plugin does not implement the {nameof(IUser)} interface", nameof(plugin));
                }

                if (storedData.ComponentCase != StDefaultComponent.ComponentOneofCase.MovingRangeTarget)
                {
                    throw new ArgumentException("Invalid component type data passed to loader", nameof(storedData));
                }

                var storedMovingRangeTarget = storedData.MovingRangeTarget;


                MovingRangeTarget = new MovingRangeTarget(storedMovingRangeTarget.InstanceID,
                                                          level,
                                                          user,
                                                          storedMovingRangeTarget.Offset.ToVector3())
                {
                    Enabled = storedMovingRangeTarget.Enabled
                };
                level.LoadRangeTarget(MovingRangeTarget);
            }
示例#2
0
            public static StDefaultComponent SaveState(MovingRangeTarget movingRangeTarget)
            {
                var storedMovingRangeTarget = new StMovingRangeTarget
                {
                    Enabled    = movingRangeTarget.Enabled,
                    InstanceID = movingRangeTarget.InstanceID,
                    Offset     = movingRangeTarget.offset.ToStVector3()
                };

                return(new StDefaultComponent {
                    MovingRangeTarget = storedMovingRangeTarget
                });
            }
示例#3
0
        public static MovingRangeTarget CreateNew <T>(T plugin, ILevelManager level, Vector3 offset)
            where T : UnitInstancePlugin, IUser
        {
            if (plugin == null)
            {
                throw new ArgumentNullException(nameof(plugin));
            }



            var newInstance = new MovingRangeTarget(level, plugin, offset);

            ((LevelManager)level).RegisterRangeTarget(newInstance);
            plugin.Entity.AddComponent(newInstance);
            return(newInstance);
        }