示例#1
0
 public MouseToolType(string iconName, DesignationType designation)
 {
     sprite = iconName != "none"
         ? IconLoader.get("orders/" + iconName)
         : null;
     this.designation = designation;
 }
示例#2
0
        public AddDesignationResult AddVoxelDesignation(VoxelHandle Voxel, DesignationType Type, Object Tag)
        {
            var key = GetVoxelQuickCompare(Voxel);

            List <VoxelDesignation> list = null;

            if (VoxelDesignations.ContainsKey(key))
            {
                list = VoxelDesignations[key];
            }
            else
            {
                list = new List <VoxelDesignation>();
                VoxelDesignations.Add(key, list);
            }

            var existingEntry = list.FirstOrDefault(d => d.Type == Type);

            if (existingEntry != null)
            {
                existingEntry.Tag = Tag;
                return(AddDesignationResult.AlreadyExisted);
            }
            else
            {
                list.Add(new VoxelDesignation
                {
                    Voxel = Voxel,
                    Type  = Type,
                    Tag   = Tag
                });
                return(AddDesignationResult.Added);
            }
        }
示例#3
0
 public bool IsDesignation(GameComponent Entity, DesignationType Type)
 {
     lock (designationLock)
     {
         return(EntityDesignations.Count(e => Object.ReferenceEquals(e.Body, Entity) && TypeSet(e.Type, Type)) != 0);
     }
 }
示例#4
0
 public IEnumerable <EntityDesignation> EnumerateEntityDesignations(DesignationType Type)
 {
     lock (designationLock)
     {
         return(EntityDesignations.Where(e => TypeSet(e.Type, Type)));
     }
 }
示例#5
0
        public DigAction(Vector3Int position, DesignationType type) : base(new PositionActionTarget(position, NEAR), "mining")
        {
            name           = "dig action";
            this.type      = type;
            startCondition = () => {
                if (!type.VALIDATOR.validate(target.getPosition().Value))
                {
                    return(FAIL);                                                      // tile still valid
                }
                if (!performer().Has <UnitEquipmentComponent>())
                {
                    return(FAIL);
                }
                if (performer().Get <UnitEquipmentComponent>().toolWithActionEquipped(toolActionName))
                {
                    return(OK);                                                                                  // tool already equipped
                }
                return(addEquipAction());
            };

            onStart = () => {
                // speed = 1 + skill().speed * performerLevel() + performance();
                // maxProgress = getWorkAmount(designation) * workAmountModifier; // 480 for wall to floor in marble
            };


            onFinish = () => {
                // BlockTypeEnum oldType = GameMvc.model().get(LocalMap.class).blockType.getEnumValue(target.getPosition());
                // if (!type.VALIDATOR.apply(target.getPosition())) return;
                // updateMap();
                // leaveStone(oldType);
                // GameMvc.model().get(UnitContainer.class).experienceSystem.giveExperience(task.performer, skill);
                // GameMvc.model().get(TaskContainer.class).designationSystem.removeDesignation(designation.position);
            };
        }
示例#6
0
        public void AddArea(IntGrid3 area, DesignationType type)
        {
            int origCount = m_map.Count;

            var locations = area.Range().Where(this.Environment.Contains);

            foreach (var p in locations)
            {
                if (GetTileValid(p, type) == false)
                    continue;

                DesignationData oldData;

                if (m_map.TryGetValue(p, out oldData))
                {
                    if (oldData.Type == type)
                        continue;

                    RemoveJob(p);
                }

                var data = new DesignationData(type);
                data.Reachable = GetTileReachable(p, type);
                m_map[p] = data;

                this.Environment.OnTileExtraChanged(p);
            }

            if (origCount == 0 && m_map.Count > 0)
            {
                this.Environment.MapTileTerrainChanged += OnEnvironmentMapTileTerrainChanged;
                this.Environment.World.TickStarting += OnTickStartEvent;
            }
        }
示例#7
0
        /// <summary>
        /// trivial validity check to remove AStar process for totally blocked tiles
        /// </summary>
        bool GetTileReachableSimple(IntVector3 p, DesignationType type)
        {
            DirectionSet dirs = GetDesignationPositioning(p, type);

            dirs = dirs.Reverse();
            return(dirs.ToSurroundingPoints(p).Any(this.Environment.CanEnter));
        }
示例#8
0
        public RemoveDesignationResult RemoveEntityDesignation(Body Entity, DesignationType Type)
        {
            if (EntityDesignations.RemoveAll(e => Object.ReferenceEquals(e.Body, Entity) && TypeSet(e.Type, Type)) != 0)
            {
                return(RemoveDesignationResult.Removed);
            }

            return(RemoveDesignationResult.DidntExist);
        }
示例#9
0
        public bool IsVoxelDesignation(VoxelHandle Voxel, DesignationType Type)
        {
            var key = VoxelHelpers.GetVoxelQuickCompare(Voxel);

            if (!VoxelDesignations.ContainsKey(key))
            {
                return(false);
            }
            return(VoxelDesignations[key].Any(d => TypeSet(d.Type, Type)));
        }
示例#10
0
        public static DesignationTypeProperties GetDesignationTypeProperties(DesignationType Of)
        {
            InitializeDesignations();

            if (Designations.ContainsKey(Of))
            {
                return(Designations[Of]);
            }
            return(DefaultDesignation);
        }
示例#11
0
 public EntityDesignation GetEntityDesignation(GameComponent Entity, DesignationType Type)
 {
     foreach (var des in EnumerateEntityDesignations(Type))
     {
         if (Object.ReferenceEquals(des.Body, Entity))
         {
             return(des);
         }
     }
     return(null);
 }
示例#12
0
 public MaybeNull <VoxelDesignation> GetVoxelDesignation(VoxelHandle Voxel, DesignationType Type)
 {
     lock (designationLock)
     {
         var key = VoxelHelpers.GetVoxelQuickCompare(Voxel);
         if (!VoxelDesignations.ContainsKey(key))
         {
             return(null);
         }
         return(VoxelDesignations[key].FirstOrDefault(d => TypeSet(d.Type, Type)));
     }
 }
示例#13
0
 public IEnumerable <VoxelDesignation> EnumerateDesignations(DesignationType Type)
 {
     foreach (var key in VoxelDesignations)
     {
         foreach (var d in key.Value)
         {
             if (TypeSet(d.Type, Type))
             {
                 yield return(d);
             }
         }
     }
 }
示例#14
0
        MineActionType DesignationTypeToMineActionType(DesignationType dtype)
        {
            switch (dtype)
            {
            case DesignationType.Mine:
                return(MineActionType.Mine);

            case DesignationType.CreateStairs:
                return(MineActionType.Stairs);

            default:
                throw new Exception();
            }
        }
示例#15
0
        DirectionSet GetDesignationPositioning(IntVector3 p, DesignationType type)
        {
            switch (type)
            {
            case DesignationType.Mine:
            case DesignationType.CreateStairs:
                return(this.Environment.GetPossibleMiningPositioning(p, DesignationTypeToMineActionType(type)));

            case DesignationType.FellTree:
                return(DirectionSet.Planar);

            default:
                throw new Exception();
            }
        }
示例#16
0
        public AddDesignationResult AddEntityDesignation(Body Entity, DesignationType Type, Object Tag = null)
        {
            if (EntityDesignations.Count(e => Object.ReferenceEquals(e.Body, Entity) && e.Type == Type) == 0)
            {
                EntityDesignations.Add(new EntityDesignation
                {
                    Body = Entity,
                    Type = Type,
                    Tag  = Tag
                });

                return(AddDesignationResult.Added);
            }

            return(AddDesignationResult.AlreadyExisted);
        }
        public void createDesignation(Vector3Int position, DesignationType type)
        {
            EcsEntity entity = GameModel.get().createEntity();

            entity.Replace(new DesignationComponent {
                type = type
            });
            entity.Replace(new PositionComponent {
                position = position
            });
            if (designations.ContainsKey(position)) // replace previous designation
            {
                cancelDesignation(position);        // cancel previous designation
            }
            designations[position] = entity;
        }
示例#18
0
        public VoxelDesignation GetVoxelDesignation(VoxelHandle Voxel, DesignationType Type)
        {
            var key = VoxelHelpers.GetVoxelQuickCompare(Voxel);

            if (!VoxelDesignations.ContainsKey(key))
            {
                return(null);
            }
            var r = VoxelDesignations[key].FirstOrDefault(d => TypeSet(d.Type, Type));

            if (r != null)
            {
                return(r);
            }
            return(null);
        }
示例#19
0
        public RemoveDesignationResult RemoveVoxelDesignation(VoxelHandle Voxel, DesignationType Type)
        {
            var key = GetVoxelQuickCompare(Voxel);

            if (!VoxelDesignations.ContainsKey(key))
            {
                return(RemoveDesignationResult.DidntExist);
            }
            var list = VoxelDesignations[key];
            var r    = list.RemoveAll(d => TypeSet(d.Type, Type)) == 0 ? RemoveDesignationResult.DidntExist : RemoveDesignationResult.Removed;

            if (list.Count == 0)
            {
                VoxelDesignations.Remove(key);
            }
            return(r);
        }
示例#20
0
        bool GetTileValid(IntVector3 p, DesignationType type)
        {
            var td = this.Environment.GetTileData(p);

            switch (type)
            {
            case DesignationType.Mine:
                return(this.Environment.GetHidden(p) || td.IsMinable);

            case DesignationType.CreateStairs:
                return(this.Environment.GetHidden(p) || (td.IsMinable && td.ID == TileID.NaturalWall));

            case DesignationType.FellTree:
                return(td.HasFellableTree);

            default:
                throw new Exception();
            }
        }
示例#21
0
        public AddDesignationResult AddEntityDesignation(GameComponent Entity, DesignationType Type, Object Tag, Task Task)
        {
            lock (designationLock)
            {
                if (EntityDesignations.Count(e => Object.ReferenceEquals(e.Body, Entity) && e.Type == Type) == 0)
                {
                    EntityDesignations.Add(new EntityDesignation
                    {
                        Body = Entity,
                        Type = Type,
                        Tag  = Tag,
                        Task = Task
                    });

                    return(AddDesignationResult.Added);
                }

                return(AddDesignationResult.AlreadyExisted);
            }
        }
示例#22
0
        public void AddArea(IntGrid3 area, DesignationType type)
        {
            int origCount = m_map.Count;

            var locations = area.Range().Where(this.Environment.Contains);

            foreach (var p in locations)
            {
                if (GetTileValid(p, type) == false)
                {
                    continue;
                }

                DesignationData oldData;

                if (m_map.TryGetValue(p, out oldData))
                {
                    if (oldData.Type == type)
                    {
                        continue;
                    }

                    RemoveJob(p);
                }

                var data = new DesignationData(type);
                data.ReachableSimple = GetTileReachableSimple(p, type);
                m_map[p]             = data;

                this.Environment.OnTileExtraChanged(p);
            }

            if (origCount == 0 && m_map.Count > 0)
            {
                this.Environment.MapTileTerrainChanged += OnEnvironmentMapTileTerrainChanged;
                this.Environment.World.TickStarted     += OnTickStartEvent;
            }
        }
示例#23
0
 public DesignationData(DesignationType type)
 {
     this.Type = type;
 }
示例#24
0
 /// <summary>
 /// trivial validity check to remove AStar process for totally blocked tiles
 /// </summary>
 bool GetTileReachableSimple(IntVector3 p, DesignationType type)
 {
     DirectionSet dirs = GetDesignationPositioning(p, type);
     dirs = dirs.Reverse();
     return dirs.ToSurroundingPoints(p).Any(this.Environment.CanEnter);
 }
示例#25
0
 public bool IsDesignation(Body Entity, DesignationType Type)
 {
     return(EntityDesignations.Count(e => Object.ReferenceEquals(e.Body, Entity) && TypeSet(e.Type, Type)) != 0);
 }
示例#26
0
        bool GetTileValid(IntVector3 p, DesignationType type)
        {
            var td = this.Environment.GetTileData(p);

            switch (type)
            {
                case DesignationType.Mine:
                    return this.Environment.GetHidden(p) || td.IsMinable;

                case DesignationType.CreateStairs:
                    return this.Environment.GetHidden(p) || (td.IsMinable && td.ID == TileID.NaturalWall);

                case DesignationType.FellTree:
                    return td.HasFellableTree;

                default:
                    throw new Exception();
            }
        }
示例#27
0
 public DesignationData(DesignationType type)
 {
     this.Type = type;
 }
示例#28
0
        bool GetTileValid(IntPoint3 p, DesignationType type)
        {
            switch (type)
            {
                case DesignationType.Mine:
                    return this.Environment.GetHidden(p) ||
                        this.Environment.GetTerrain(p).IsMinable;

                case DesignationType.CreateStairs:
                    return this.Environment.GetHidden(p) ||
                        (this.Environment.GetTerrain(p).IsMinable && this.Environment.GetTerrainID(p) == TerrainID.NaturalWall);

                case DesignationType.Channel:
                    // XXX
                    return true;

                case DesignationType.FellTree:
                    return this.Environment.GetInteriorID(p).IsFellableTree();

                default:
                    throw new Exception();
            }
        }
示例#29
0
        DirectionSet GetDesignationPositioning(IntVector3 p, DesignationType type)
        {
            switch (type)
            {
                case DesignationType.Mine:
                case DesignationType.CreateStairs:
                    return this.Environment.GetPossibleMiningPositioning(p, DesignationTypeToMineActionType(type));

                case DesignationType.FellTree:
                    return DirectionSet.Planar;

                default:
                    throw new Exception();
            }
        }
示例#30
0
        bool GetTileReachable(IntPoint3 p, DesignationType type)
        {
            DirectionSet dirs;

            // trivial validity check to remove AStar process for totally blocked tiles

            switch (type)
            {
                case DesignationType.Mine:
                    dirs = DirectionSet.Planar;
                    // If the tile below has stairs, tile tile can be mined from below
                    if (EnvironmentHelpers.CanMoveFrom(this.Environment, p + Direction.Down, Direction.Up))
                        dirs |= DirectionSet.Down;
                    break;

                case DesignationType.CreateStairs:
                    dirs = DirectionSet.Planar | DirectionSet.Up;
                    if (EnvironmentHelpers.CanMoveFrom(this.Environment, p + Direction.Down, Direction.Up))
                        dirs |= DirectionSet.Down;
                    break;

                case DesignationType.Channel:
                    dirs = DirectionSet.Planar;
                    break;

                case DesignationType.FellTree:
                    dirs = DirectionSet.Planar;
                    break;

                default:
                    throw new Exception();
            }

            return dirs.ToDirections()
                .Any(d => EnvironmentHelpers.CanEnter(this.Environment, p + d));
        }
示例#31
0
 MineActionType DesignationTypeToMineActionType(DesignationType dtype)
 {
     switch (dtype)
     {
         case DesignationType.Mine:
             return MineActionType.Mine;
         case DesignationType.CreateStairs:
             return MineActionType.Stairs;
         default:
             throw new Exception();
     }
 }
示例#32
0
 private static bool TypeSet(DesignationType DesType, DesignationType FilterType)
 {
     return((FilterType & DesType) != 0);
 }
示例#33
0
        public string RegisterStaffFaculty(RegistrationFormData registrationFormData, List <Files> fileDetail, IFormFileCollection FileCollection)
        {
            string          StaffUid        = "";
            string          ImagePath       = this.beanContext.GetContentRootPath();
            string          output          = string.Empty;
            DesignationType designationType = DesignationType.Faculty;

            if (string.IsNullOrEmpty(registrationFormData.Email))
            {
                registrationFormData.Email = null;
            }
            if (!string.IsNullOrEmpty(registrationFormData.StaffMemberUid))
            {
                StaffUid = registrationFormData.StaffMemberUid;
            }
            ServiceResult serviceResult = validateModalService.ValidateModalFieldsService(typeof(RegistrationFormData), registrationFormData);

            if (registrationFormData.ApplicationFor == DesignationType.Faculty.ToString().ToLower())
            {
                designationType = DesignationType.Faculty;
            }
            else if (registrationFormData.ApplicationFor == DesignationType.Driver.ToString().ToLower())
            {
                designationType = DesignationType.Driver;
            }
            else
            {
                designationType = DesignationType.Other;
            }
            if (serviceResult.IsValidModal)
            {
                DbParam[] param = new DbParam[]
                {
                    new DbParam(StaffUid, typeof(System.String), "_StaffMemberUid"),
                    new DbParam(userDetail.schooltenentId, typeof(System.String), "_schooltenentid"),
                    new DbParam(registrationFormData.FirstName, typeof(System.String), "_FirstName"),
                    new DbParam(registrationFormData.LastName, typeof(System.String), "_LastName"),
                    new DbParam(registrationFormData.Gender, typeof(System.Boolean), "_Gender"),
                    new DbParam(registrationFormData.Dob, typeof(System.DateTime), "_Dob"),
                    new DbParam(registrationFormData.MobileNumber, typeof(System.String), "_MobileNumber"),
                    new DbParam(registrationFormData.AlternetNumber, typeof(System.String), "_AlternetNumber"),
                    new DbParam(registrationFormData.Email, typeof(System.String), "_Email"),
                    new DbParam(registrationFormData.Address, typeof(System.String), "_Address"),
                    new DbParam(registrationFormData.State, typeof(System.String), "_State"),
                    new DbParam(registrationFormData.City, typeof(System.String), "_City"),
                    new DbParam(registrationFormData.Pincode, typeof(System.Int64), "_Pincode"),
                    new DbParam(registrationFormData.Subjects, typeof(System.String), "_Subjects"),
                    new DbParam(registrationFormData.Type, typeof(System.String), "_Type"),
                    new DbParam(registrationFormData.SchoolUniversityName, typeof(System.String), "_SchoolUniversityName"),
                    new DbParam(designationType, typeof(System.Int32), "_DesignationId"),
                    new DbParam(registrationFormData.ProofOfDocumentationPath, typeof(System.String), "_ProofOfDocumentationPath"),
                    new DbParam(registrationFormData.DegreeName, typeof(System.String), "_DegreeName"),
                    new DbParam(registrationFormData.Grade, typeof(System.String), "_Grade"),
                    new DbParam(registrationFormData.Position, typeof(System.String), "_Position"),
                    new DbParam(registrationFormData.MarksObtain, typeof(System.Double), "_MarksObtain"),
                    new DbParam(registrationFormData.Title, typeof(System.String), "_Title"),
                    new DbParam(registrationFormData.ExprienceInYear, typeof(System.String), "_ExprienceInYear"),
                    new DbParam(registrationFormData.ExperienceInMonth, typeof(System.String), "_ExperienceInMonth"),
                    new DbParam(registrationFormData.ImageUrl, typeof(System.String), "_ImageUrl"),
                    new DbParam(userDetail.UserId, typeof(System.String), "_AdminId"),
                    new DbParam(registrationFormData.AccessLevelUid, typeof(System.String), "_AccessLevelUid"),
                    new DbParam(registrationFormData.ClassDetailUid, typeof(System.String), "_ClassDetailId")
                };
                output = db.ExecuteNonQuery("sp_RegisterStaffAndFacultyDetails_InsUpd", param, true);
                if (!string.IsNullOrEmpty(output) && output != "fail")
                {
                    if (FileCollection.Count > 0)
                    {
                        string FolderPath = Path.Combine(this.currentSession.FileUploadFolderName,
                                                         ApplicationConstant.Faculty,
                                                         output);
                        List <Files> files = this.fileService.SaveFile(FolderPath, fileDetail, FileCollection, output);
                        if (files != null && files.Count > 0)
                        {
                            DataSet fileDs = this.beanContext.ConvertToDataSet <Files>(files);
                            if (fileDs != null && fileDs.Tables.Count > 0 && fileDs.Tables[0].Rows.Count > 0)
                            {
                                DataTable table = fileDs.Tables[0];
                                table.TableName = "Files";
                                db.InsertUpdateBatchRecord("sp_Files_InsUpd", table);
                                output = "Record inserted successfully.";
                            }
                        }
                        else
                        {
                            ///==========  Log information ====================
                            output = "Record updated successfully.";
                        }
                    }
                    else
                    {
                        output = "Record inserted/updated successfully.";
                    }
                }
            }
            else
            {
                output = JsonConvert.SerializeObject(serviceResult.ErrorResultedList);
            }

            return(output);
        }