Ejemplo n.º 1
0
 public override void UpdateBeforeSimulation()
 {
     if (!m_init || MyAPIGateway.Session != null)
     {
         m_init = true;
         HackingComputerSync.Initialize();
     }
 }
Ejemplo n.º 2
0
        public override void UpdateAfterSimulation100()
        {
            if (!MyAPIGateway.Multiplayer.IsServer)
            {
                return;
            }

            try
            {
                m_sink.Update();
                if (!IsWorking() || m_hackingblock.OwnerId == 0)
                {
                    CurrentState = States.Off;
                }
                else
                {
                    List <IMySlimBlock> blocks = new List <IMySlimBlock>();
                    (m_hackingblock.CubeGrid as IMyCubeGrid).GetBlocks(blocks, isValidHackingTarget);
                    if (blocks.Count > 0)
                    {
                        int targetIndex = m_random.Next(blocks.Count);

                        for (int i = 0; i < blocks.Count; i++)
                        {
                            if (blocks[i].GetObjectBuilder().GetId().SubtypeName == "LargeFirewallBlock")
                            {
                                FirewallBlock firewall = blocks[i].FatBlock.GameLogic.GetAs <FirewallBlock>();
                                if (firewall == null)
                                {
                                    LogManager.WriteLine("Firewall Has No Firewall Component");
                                }
                                else if (firewall.IsWorking())
                                {
                                    targetIndex = i;
                                }
                            }
                        }

                        IMySlimBlock block = blocks[targetIndex];

                        Chance   = getComputerCount(block);
                        TargetId = block.FatBlock.EntityId;

                        if (m_random.Next() % Chance == 0)
                        {
                            (block.FatBlock as MyCubeBlock).ChangeOwner(0, MyOwnershipShareModeEnum.Faction);
                            (block.FatBlock as MyCubeBlock).ChangeBlockOwnerRequest(m_hackingblock.OwnerId, MyOwnershipShareModeEnum.Faction);

                            // Success
                            CurrentState = States.Success;
                        }
                        else
                        {
                            // Failure
                            CurrentState = States.Hacking;
                        }
                    }
                    else
                    {
                        // No Enemies
                        TargetId     = 0L;
                        CurrentState = States.NoEnemies;
                    }
                }
            }
            catch (Exception e)
            {
                LogManager.WriteException(e);
            }

            HackingComputerSync.SendHackingBlockStates(this);
        }
Ejemplo n.º 3
0
 protected override void UnloadData()
 {
     HackingComputerSync.Unload();
     LogManager.Unload();
 }