Example #1
0
        public ActionResult Add(AddBargeViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // was barge info exsited?
                    var existed = db.Barges.Where(b => string.Compare(b.BargeCode, model.BargeCode, true) == 0).FirstOrDefault();
                    if (existed != null)
                    {
                        ModelState.AddModelError("", "Sà lan số [" + model.BargeCode + "] đã tồn tại trong hệ thống!");
                        return(View(model));
                    }

                    // create new barge info
                    var newBarge = new Barge();
                    newBarge.BargeCode                 = model.BargeCode;
                    newBarge.VolumeRevenue             = model.VolumeRevenue;
                    newBarge.VolumePurchaseGoldSand    = model.VolumePurchaseGoldSand;
                    newBarge.VolumePurchaseFillingSand = model.VolumePurchaseFillingSand;
                    newBarge.Description               = model.Description;

                    // save new barge info
                    db.Barges.Add(newBarge);
                    db.SaveChanges();

                    // write action logs data
                    var log_data = "id=" + newBarge.BargeId + ",code=" + newBarge.BargeCode +
                                   ",v1=" + newBarge.VolumeRevenue +
                                   ",v2=" + newBarge.VolumePurchaseFillingSand +
                                   ",v3=" + newBarge.VolumePurchaseGoldSand;
                    ActionLog.WriteLog(ActionLog.ADD_BARGE_INFO, log_data, User.Identity.Name, Request.ServerVariables["REMOTE_ADDR"]);

                    return(RedirectToAction("Index"));
                }

                // invalid boat info
                ModelState.AddModelError("", "Thông tin sà lan không hợp lệ!");
            }
            catch (Exception ex)
            {
                // error
                ModelState.AddModelError("", ex.Message);
            }

            return(View(model));
        }
Example #2
0
        public virtual Ship CreatePlayerShip(World world, Vector2 position, int shipID, float rotation,
                                             Vector2 velocity, string playerName, ShipStats shipStats, List <WeaponTypes> weaponTypes, HashSet <int> teams)
        {
            if (PlayerShip != null)
            {
                _teamManager.DeRegisterObject(PlayerShip);
                _targetManager.DeRegisterObject(PlayerShip);
                if (PlayerShip.IsBodyValid)
                {
                    Debugging.DisposeStack.Push(this.ToString());
                    PlayerShip.Body.Dispose();
                }
            }

            if (_shipList.ContainsKey(shipID))
            {
                _positionUpdateList.Remove(_shipList[shipID]);

                _shipList.Remove(shipID);
            }

            Ship tempShip;


            switch (shipStats.ShipType)
            {
            case ShipTypes.Barge:
                tempShip = new Barge(position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName,
                                     shipStats, _particleManager,
                                     world, _spriteBatch, GetTexture(shipStats.ShipType), teams);
                break;

            case ShipTypes.SuperCoolAwesome3DShip:
                tempShip = new SuperCoolAwesome3DShip(_spriteBatch, GetModel(shipStats.ShipType), position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName,
                                                      shipStats, _particleManager,
                                                      world, teams);
                break;

            case ShipTypes.Reaper:
                tempShip = new Reaper(position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName,
                                      shipStats, _particleManager,
                                      world, _spriteBatch, GetTexture(shipStats.ShipType), teams);
                break;

            case ShipTypes.BattleCruiser:
                tempShip = new Battlecruiser(position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName,
                                             shipStats, _particleManager,
                                             world, _spriteBatch, GetTexture(shipStats.ShipType), teams);
                break;

            case ShipTypes.Penguin:
                tempShip = new Penguin(position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName,
                                       shipStats, _particleManager,
                                       world, _spriteBatch, GetTexture(shipStats.ShipType), teams);
                break;

            case ShipTypes.Dread:
                tempShip = new Dread(position, velocity, rotation, shipID, (int)_clientPlayerInfoManager.PlayerID, playerName,
                                     shipStats, _particleManager,
                                     world, _spriteBatch, GetTexture(shipStats.ShipType), teams);
                break;

            default:
                Console.WriteLine("Ship type not implemented in ClientShipManager.CreatePlayerShip");
                return(null);
            }

            byte slot = 0;

            foreach (var w in weaponTypes)
            {
                tempShip.SetWeapon(_createWeapon(tempShip, _projectileManager, w, slot), slot);
                slot++;
            }

            SetPilot(tempShip, Debugging.IsBot);

            _shipList.Add(tempShip.Id, tempShip);
            _positionUpdateList.Add(tempShip);

            _playerShipManager.PlayerShip = tempShip;
            _teamManager.RegisterObject(tempShip);

            _updateIgnoreList.Add(PlayerShip.Id);


            tempShip.CanLandWarp = true;
            return(tempShip);
        }
    public int DAT_94;     //0x94

    //FUN_24CC (HARBOR.DLL)
    public override uint UpdateW(int arg1, int arg2)
    {
        sbyte           sVar1;
        VigObject       oVar2;
        int             iVar3;
        RSEG_DB         unaff_s3;
        CraneLarge      ppcVar4;
        int             iVar6;
        RSEG_DB         rVar6;
        long            lVar6;
        VigObject       oVar6;
        ConfigContainer ccVar6;
        RSEG_DB         piVar7;
        JUNC_DB         jVar8;
        int             iVar9;
        JUNC_DB         jVar9;
        Vector3Int      local_50;
        Vector3Int      local_40;
        Vector3Int      local_38;
        Vector3Int      local_30;

        switch (arg1)
        {
        case 0:
            break;

        case 1:
            rVar6  = LevelManager.instance.FUN_518DC(screen, id - 100);
            DAT_88 = rVar6;
            DAT_90 = 1;
            iVar9  = rVar6.FUN_51334(screen);
            DAT_94 = iVar9 << 16;
            DAT_8C = 6103;
            flags |= 0x88;
            return(0);

        case 2:
            iVar6 = 120;

            if (id == 117)
            {
                iVar6 = 121;
            }

            ppcVar4 = (CraneLarge)GameManager.instance.FUN_318D0(iVar6);

            if (ppcVar4.GetType().IsSubclassOf(typeof(VigObject)))
            {
                ppcVar4.UpdateW(21, null);
            }

            FUN_30B78();
            return(0);

        case 4:
            iVar6 = 120;

            if (id == 117)
            {
                iVar6 = 121;
            }

            ppcVar4 = (CraneLarge)GameManager.instance.FUN_318D0(iVar6);

            if (!ppcVar4.GetType().IsSubclassOf(typeof(VigObject)))
            {
                return(0);
            }

            ppcVar4.UpdateW(21, null);
            return(0);

        default:
            return(0);

        case 8:
            FUN_32B90((uint)arg2);
            return(0);

        case 9:
            if (arg2 != 0)
            {
                GameManager.instance.FUN_309A0(this);
                return(0);
            }

            return(0);
        }

        switch (((byte)tags - 1) * 0x1000000 >> 24)
        {
        case 0:
        case 8:
            iVar9 = DAT_8C + 33;
            goto LAB_261C;

        case 1:
        case 4:
            if (DAT_84 == null)
            {
                goto case 12;
            }

            if (DAT_84.tags == 0)
            {
                goto case 5;
            }

            if (DAT_90 == 0)
            {
                iVar9 = DAT_94;
            }
            else
            {
                iVar9 = 0x10000000 - DAT_94;
            }

            if (iVar9 < 0)
            {
                iVar9 += 0xffff;
            }

            iVar9 = (iVar9 >> 16) * 4577;

            if (iVar9 < 0)
            {
                iVar9 += 4095;
            }

            goto LAB_2694;

        case 2:
        case 5:
            if (DAT_84 == null || DAT_84.tags == 0)
            {
                goto case 12;
            }

            break;

        case 6:
        case 7:
            if (DAT_90 == 0)
            {
                iVar9 = DAT_94;
            }
            else
            {
                iVar9 = 0x10000000 - DAT_94;
            }

            if (iVar9 < 0)
            {
                iVar9 += 0xffff;
            }

            iVar9 = (iVar9 >> 16) * 4577;

            if (iVar9 < 0)
            {
                iVar9 += 4095;
            }

LAB_2694:
            iVar3 = 305;

            if (305 < iVar9 >> 12)
            {
                iVar3 = iVar9 >> 12;
            }

            DAT_8C = iVar3;
            break;

        case 11:
            iVar9 = DAT_8C + 3;
            goto LAB_261C;

        case 12:
            iVar9 = DAT_8C + 33;
LAB_261C:
            iVar3 = 6103;

            if (iVar9 < 6103)
            {
                iVar3 = iVar9;
            }

            DAT_8C = iVar3;
            break;
        }

        iVar9 = DAT_94;
        iVar6 = vTransform.position.y;

        if (iVar9 < 0)
        {
            iVar9 += 0xffff;
        }

        DAT_88.FUN_285E4(iVar9 >> 16, ref vTransform.position, out local_50);
        vTransform.position.y = iVar6;
        local_38 = new Vector3Int();
        iVar6    = FUN_2CFBC(vTransform.position, ref local_38);
        vTransform.position.y = iVar6;

        if (DAT_90 == 0)
        {
            local_50.x = -local_50.x;
            local_50.z = -local_50.z;
        }

        local_50.y = -(local_50.x * local_38.x + local_50.z * local_38.z) / local_38.y;
        lVar6      = Utilities.VectorNormal2(local_50, out local_30);
        iVar9      = (int)Utilities.SquareRoot(lVar6);

        if (DAT_90 == 0)
        {
            iVar3 = DAT_8C * -0x10000;
        }
        else
        {
            iVar3 = DAT_8C << 16;
        }

        DAT_94  += iVar3 / iVar9;
        local_40 = Utilities.FUN_2A1E0(local_38, local_30);
        vTransform.rotation.V00 = (short)-local_40.x;
        vTransform.rotation.V10 = (short)-local_40.y;
        vTransform.rotation.V20 = (short)-local_40.z;
        vTransform.rotation.V01 = (short)-local_38.x;
        vTransform.rotation.V11 = (short)-local_38.y;
        vTransform.rotation.V22 = (short)-local_38.z;
        vTransform.rotation.V02 = (short)local_30.x;
        vTransform.rotation.V12 = (short)local_30.y;
        vTransform.rotation.V22 = (short)local_30.z;

        if ((uint)DAT_94 < 0x10000001)
        {
            return(0);
        }

        piVar7   = DAT_88;
        jVar8    = piVar7.DAT_00[DAT_90];
        iVar3    = 0;
        unaff_s3 = null; //not in the original code

        if (jVar8.DAT_11 != 0)
        {
            do
            {
                unaff_s3 = jVar8.DAT_1C[iVar3];

                if (unaff_s3 != piVar7 && unaff_s3.DAT_08 == piVar7.DAT_08)
                {
                    break;
                }

                iVar3++;
            } while (iVar3 < jVar8.DAT_11);
        }

        DAT_88 = unaff_s3;
        jVar9  = unaff_s3.DAT_00[0];
        DAT_90 = jVar9 == jVar8 ? 1 : 0;
        DAT_94 = ((jVar9 == jVar8 ? 1 : 0) == 0 ? 1 : 0) << 28;

        if ((jVar8.DAT_10 & 0x40) == 0)
        {
            return(0);
        }

        sVar1 = (sbyte)jVar8.DAT_12;
        tags  = sVar1;

        switch (sVar1)
        {
        case 1:
            FUN_30BA8();
            GameManager.instance.FUN_30CB0(this, 600);
            iVar6 = 120;

            if (id == 117)
            {
                iVar6 = 121;
            }

            ppcVar4 = (CraneLarge)GameManager.instance.FUN_318D0(iVar6);

            if (ppcVar4.GetType().IsSubclassOf(typeof(VigObject)))
            {
                ppcVar4.UpdateW(21, this);
            }

            break;

        case 2:
            iVar6 = 49;
            goto LAB_29EC;

        case 3:
        case 6:
            if (DAT_84 != null)
            {
                if (DAT_84.tags != 0)
                {
                    DAT_8C = 0;
                    return(0);
                }

                return(0);
            }

            break;

        case 4:
            if (DAT_80 == null)
            {
                ccVar6 = FUN_2C5F4(0x8000);
                oVar2  = Barge.FUN_1F64();
                DAT_80 = oVar2;
                Utilities.FUN_2CB04(this, ccVar6, oVar2);
                Utilities.ParentChildren(this, this);
                return(0);
            }

            return(0);

        case 5:
            iVar6 = 50;
LAB_29EC:
            oVar6  = GameManager.instance.FUN_318D0(iVar6);
            DAT_84 = oVar6;
            break;

        case 9:
            FUN_30BA8();
            GameManager.instance.FUN_30CB0(this, 180);
            return(0);

        case 10:
            if (DAT_80 == null)
            {
                return(0);
            }

            oVar6 = DAT_80.FUN_2CCBC();
            GameManager.instance.FUN_307CC(oVar6);
            DAT_80 = null;
            break;
        }

        return(0);
    }
Example #4
0
        /// <summary>
        /// Used to create new network or NPC ships
        /// DO NOT USE FOR PLAYERSHIP
        /// ignorePositionUpdates should only be used by the Simulator
        /// </summary>
        public Ship CreateShip(World world, bool isNPC, Vector2 position, int shipID, float rotation, Vector2 velocity,
                               string playerName,
                               ShipStats shipStats, List <WeaponTypes> weaponTypes, HashSet <int> teams, bool ignorePositionUpdates = false)
        {
            Ship tempShip;


            _targetManager.DisableTargetSetting();

            switch (shipStats.ShipType)
            {
            case ShipTypes.Barge:
                tempShip = new Barge(position, velocity, rotation, shipID, 0,
                                     playerName, shipStats,
                                     _particleManager,
                                     world, _spriteBatch, GetTexture(shipStats.ShipType), teams);
                tempShip.Pilot = new NetworkPilot(tempShip, new ShipBodyDataObject(BodyTypes.NetworkShip, shipID, tempShip));
                break;

            case ShipTypes.Reaper:
                tempShip = new Reaper(position, velocity, rotation, shipID, 0, playerName,
                                      shipStats,
                                      _particleManager,
                                      world, _spriteBatch, GetTexture(shipStats.ShipType), teams);
                tempShip.Pilot = new NetworkPilot(tempShip, GenerateNetworkShipBodyData(shipID, tempShip));
                break;

            case ShipTypes.SuperCoolAwesome3DShip:
                tempShip = new SuperCoolAwesome3DShip(_spriteBatch, GetModel(shipStats.ShipType), position, velocity, rotation, shipID, 0,
                                                      playerName, shipStats,
                                                      _particleManager,
                                                      world, teams);
                tempShip.Pilot = new NetworkPilot(tempShip, new ShipBodyDataObject(BodyTypes.NetworkShip, shipID, tempShip));
                break;


            case ShipTypes.BattleCruiser:
                tempShip = new Battlecruiser(position, velocity, rotation, shipID, 0,
                                             playerName, shipStats,
                                             _particleManager,
                                             world, _spriteBatch, GetTexture(shipStats.ShipType), teams);
                tempShip.Pilot = new NetworkPilot(tempShip, GenerateNetworkShipBodyData(shipID, tempShip));
                break;

            case ShipTypes.Penguin:
                tempShip = new Penguin(position, velocity, rotation, shipID, 0,
                                       playerName, shipStats,
                                       _particleManager,
                                       world, _spriteBatch, GetTexture(shipStats.ShipType), teams);
                tempShip.Pilot = new NetworkPilot(tempShip, GenerateNetworkShipBodyData(shipID, tempShip));
                break;

            case ShipTypes.Dread:
                tempShip = new Dread(position, velocity, rotation, shipID, 0,
                                     playerName, shipStats,
                                     _particleManager,
                                     world, _spriteBatch, GetTexture(shipStats.ShipType), teams);
                tempShip.Pilot = new NetworkPilot(tempShip, GenerateNetworkShipBodyData(shipID, tempShip));

                break;

            default:
                ConsoleManager.WriteLine("Ship type not implemented in ClientShipManager.CreateShip",
                                         ConsoleMessageType.Error);
                return(null);
            }

            if (!_simulateNPCs || tempShip.Pilot.PilotType == PilotType.NetworkPlayer)
            {
                tempShip.BodyBehaviors.Add(new LerpBodyBehavior(_spriteBatch, _textureManager, tempShip, 100));
            }

            tempShip.IsLocalSim = (_simulateNPCs && isNPC);
            AddShip(shipID, tempShip);

            byte numSet = 0;

            foreach (var t in weaponTypes)
            {
                tempShip.SetWeapon(_createWeapon(tempShip, _projectileManager, t, numSet), numSet);
                numSet++;
            }


            tempShip.Pilot = isNPC
                ? new NPCPilot(tempShip, GenerateNetworkShipBodyData(shipID, tempShip))
                : new NPCPilot(tempShip, new ShipBodyDataObject(BodyTypes.NetworkShip, shipID, tempShip));

            if (ignorePositionUpdates)
            {
                _updateIgnoreList.Add(tempShip.Id);
            }

            _targetManager.EnableTargetSetting();


            return(tempShip);
        }