private void OnStructureAdded(Structures.Structure obj)
        {
            WeaponFireSynchronizer syncer = obj.GetComponentInChildren <WeaponFireSynchronizer>();

            if (syncer)
            {
                bool allTrue = true;
                int  amount  = 0;
                foreach (TurretWeapon weapon in syncer.GetComponentsInChildren <TurretWeapon>())
                {
                    if (!weapon.Identifier.Contains(WeaponIdentifier))
                    {
                        allTrue = false;
                    }
                    else
                    {
                        amount++;
                    }
                }
                if (allTrue && amount == WeaponAmount)
                {
                    _onCompletedCallback();
                    _onProgressedCallback();
                    _completed = true;
                }
            }
        }
Ejemplo n.º 2
0
        private Traffic GetSquadsOnStructure_CMD(string args)
        {
            StructureCommand command = JsonConvert.DeserializeObject <StructureCommand>(args);
            MessageTypes     type    = MessageTypes.None;
            string           message = "";

            if (_server.WorldLoaded)
            {
                if (_server.Users.SessionKeyExists(command.sessionKey))
                {
                    User user = _server.Users.GetConnectedUser(command.sessionKey);
                    if (_server.Structures.OpExists(command.location))
                    {
                        Structures.Structure structure = _server.Structures.GetStructure(command.location);
                        User.Standing        standings = structure.Owner.GetStandings(user);
                        if (standings == User.Standing.Own || standings == User.Standing.Ally)
                        {
                            Units.Squad[]    units   = structure.GetSquads();
                            List <SquadInfo> unitInf = new List <SquadInfo>();
                            for (int i = 0; i < units.Length; i++)
                            {
                                unitInf.Add(new SquadInfo(units[i].owner.Name, units[i].name, units[i].ident,
                                                          (SquadInfo.SquadStanding)standings, new Vector2Int(), new Vector2Int(),
                                                          structure.Location, false));
                            }
                            StructureSquads str_unt = new StructureSquads(structure.Location, unitInf.ToArray());
                            return(new Traffic("SetStructureSquads", JsonConvert.SerializeObject(str_unt)));
                        }
                        else
                        {
                            type = MessageTypes.Invalid_Permission;
                        }
                    }
                    else
                    {
                        type = MessageTypes.No_OP;
                    }
                }
                else
                {
                    type = MessageTypes.Not_Logged_in;
                }
            }
            else
            {
                type = MessageTypes.World_Not_Loaded;
            }
            return(new Traffic("message", JsonConvert.SerializeObject(new Message("_server_", type, message))));
        }