public void OnStart()
    {
        foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col0"))
        {
            _col0Lights.Add(obj.RequireComponent <CLight>());
            _allLights.Add(obj.RequireComponent <CLight>());
        }
        foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col1"))
        {
            _col1Lights.Add(obj.RequireComponent <CLight>());
            _allLights.Add(obj.RequireComponent <CLight>());
        }
        foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col2"))
        {
            _col2Lights.Add(obj.RequireComponent <CLight>());
            _allLights.Add(obj.RequireComponent <CLight>());
        }
        foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col3"))
        {
            _col3Lights.Add(obj.RequireComponent <CLight>());
            _allLights.Add(obj.RequireComponent <CLight>());
        }

        chilloutFace  = GameObject.GetGameObjectByName("lastchilloutface");
        faceRender    = chilloutFace.RequireComponent <CSkinMeshRenderer>();
        faceTransform = chilloutFace.RequireComponent <CTransform>();
        faceRender.setEnabled(false);

        distortScript = GetScript <DistortForTime>(gameObject);

        currAliveTimer = MMath.GetRandomLimitedFloat(_monsterMinActiveTime, _monsterMaxActiveTime);

        sound = gameObject.RequireComponent <CSound>();
    }
    void Init()
    {
        if (!isInit)
        {
            isInit = true;

            defaultColor   = SharpMocha.WHITE;
            defaultColor.a = alphaValue;
            greenColor     = SharpMocha.GREEN;
            greenColor.a   = alphaValue;
            redColor       = SharpMocha.RED;
            redColor.a     = alphaValue;

            GameObject controller = GameObject.GetGameObjectByName(Common.prefix + "PuzzleRoom3", false);
            if (controller != null)
            {
                controllerScript = GetScript <DeathPanelController>(controller);
            }
            else
            {
                Logger.Log("Unable to find DeathPanelController");
            }

            GameObject obj = Common.GetChildByName(gameObject, Common.prefix + "DeathPanelScreen");
            screen     = obj.RequireComponent <CForwardRenderer>();
            obj        = Common.GetChildByName(gameObject, Common.prefix + "DeathPanelText");
            numberText = obj.RequireComponent <CFontRenderer>();
        }
    }
    public void OnStart()
    {
        foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col0"))
        {
            _col0Lights.Add(obj.RequireComponent<CLight>());
            _allLights.Add(obj.RequireComponent<CLight>());
        }
        foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col1"))
        {
            _col1Lights.Add(obj.RequireComponent<CLight>());
            _allLights.Add(obj.RequireComponent<CLight>());
        }
        foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col2"))
        {
            _col2Lights.Add(obj.RequireComponent<CLight>());
            _allLights.Add(obj.RequireComponent<CLight>());
        }
        foreach (GameObject obj in GameObject.GetGameObjectsWithTag("col3"))
        {
            _col3Lights.Add(obj.RequireComponent<CLight>());
            _allLights.Add(obj.RequireComponent<CLight>());
        }

        chilloutFace = GameObject.GetGameObjectByName("lastchilloutface");
        faceRender = chilloutFace.RequireComponent<CSkinMeshRenderer>();
        faceTransform  = chilloutFace.RequireComponent<CTransform>();
        faceRender.setEnabled(false);

        distortScript = GetScript<DistortForTime>(gameObject);

        currAliveTimer = MMath.GetRandomLimitedFloat(_monsterMinActiveTime, _monsterMaxActiveTime);

        sound = gameObject.RequireComponent<CSound>();
    }
Beispiel #4
0
    private void AddCollisionMesh()
    {
        // TODO: we should be able to use CallerMemberName for something nicer with a later C# version
        Profiler.BeginSample("WavyIslandMapGenerator.AddCollisionMesh");

        //Debug.Log("Writing map to mesh");
        _collisionMeshFilters   = new MeshFilter[_map.MapChunks.Length];
        _collisionMeshColliders = new MeshCollider[_map.MapChunks.Length];

        // TODO: need to generate collision geometry for the gap between chunks
        // either do that as one extra pass at the end, or maybe offset all the chunks by one square so that the right
        // geometry gets created? (latter option would have to be implemented back in the map generator which is a bit
        // icky, but maybe it's actually the right thing to do since it means we can treat each map chunk as a whole map
        // in its own right)

        for (var i = 0; i < _map.MapChunks.Length; i++)
        {
            var chunk         = _map.MapChunks[i];
            var collisionMesh = new Mesh();
            WriteMapToCollisionMesh(chunk, collisionMesh);

            var mapCollisionName = "MapCollision_" + i;
            var mapCollision     =
                new GameObject(mapCollisionName, typeof(MeshFilter), typeof(MeshCollider) /*, typeof(MeshRenderer)*/);
            mapCollision.transform.SetParent(transform, false);
            var meshFilter = mapCollision.RequireComponent <MeshFilter>();
            meshFilter.mesh          = collisionMesh;
            _collisionMeshFilters[i] = meshFilter;
            var meshCollider = mapCollision.RequireComponent <MeshCollider>();
            meshCollider.sharedMesh    = collisionMesh;
            _collisionMeshColliders[i] = meshCollider;
        }

        Profiler.EndSample();
    }
    public void OnStart()
    {
        //base.OnStart();
        currAliveTimer = MMath.GetRandomLimitedFloat(_monsterMinActiveTime, _monsterMaxActiveTime);
        currDeadTimer = MMath.GetRandomLimitedFloat(_monsterMinRestTime, _monsterMaxRestTime);

        chilloutFace = GameObject.GetGameObjectByName("maxChill");
        faceRender = chilloutFace.RequireComponent<CSkinMeshRenderer>();
        faceTransform  = chilloutFace.RequireComponent<CTransform>();
        faceRender.setEnabled(false);

        distortScript = GetScript<DistortForTime>(gameObject);
    }
Beispiel #6
0
    public void OnStart()
    {
        //base.OnStart();
        currAliveTimer = MMath.GetRandomLimitedFloat(_monsterMinActiveTime, _monsterMaxActiveTime);
        currDeadTimer  = MMath.GetRandomLimitedFloat(_monsterMinRestTime, _monsterMaxRestTime);

        chilloutFace  = GameObject.GetGameObjectByName("maxChill");
        faceRender    = chilloutFace.RequireComponent <CSkinMeshRenderer>();
        faceTransform = chilloutFace.RequireComponent <CTransform>();
        faceRender.setEnabled(false);

        distortScript = GetScript <DistortForTime>(gameObject);
    }
    public void OnStart()
    {
        offPointLightColor = new Color(0.8f, 0.0f, 0.0f, 1.0f);
        onPointLightColor  = new Color(0.0f, 0.8f, 0.0f, 1.0f);

        // Initialize into the common list
        GameObject camInMap;

        Common.AddCameraObjectToList(gameObject, out camInMap, out camInMapArea);
        CameraInMap inMapScript = GetScript <CameraInMap>(camInMapArea);

        inMapScript.SetTwin(gameObject); // Set in map to be able to direct to me (camInWorld)
        if (gameObject == Common.GetRCCarCam())
        {
            inMapScript.isActive = true; // always default RCCar to active
        }

        prevXCurrRot = xCurrRot = 0.0f;
        prevYCurrRot = yCurrRot = 0.0f;

        UpdateVectors();

        if (xRotationLimit == 0.0f && yRotationLimit == 0.0f)
        {
            shouldPhysicalCameraRotate = false;
        }

        for (uint i = 0; i < gameObject.transform.GetNumberOfChildren(); ++i)
        {
            GameObject childObj = gameObject.transform.GetChild(i).gameObject;
            if (childObj.GetName() == Common.nameForCamLight)
            {
                spotlight = childObj.RequireComponent <CLight>();
                spotlight.SetDiffuse(new Color(0.706f, 0.96f, 0.714f, 1.0f)); // FFB4FCB6
                // spotlight.SetRange(10.0f);
                // spotlight.SetSpot(10.0f);
                // spotlight.SetAtt(1.0f);
                // spotlight.SetLightType(CLight.LIGHTTYPE.SPOTLIGHT);
                spotlight.setEnabled(false);
            }
            else if (childObj.GetName() == Common.nameForCamPointLight)
            {
                pointlight = childObj.RequireComponent <CLight>();
                SetPointLight(false);
                pointlight.setEnabled(true);
            }
        }

        mSound       = gameObject.RequireComponent <CSound>();
        mCamRotateID = mSound.GetUniqueEvent("CAM_ROTATE.vente", 1);
    }
        public override void Process(CyclopsDecoyLaunch decoyLaunchPacket)
        {
            GameObject          cyclops      = GuidHelper.RequireObjectFrom(decoyLaunchPacket.Guid);
            CyclopsDecoyManager decoyManager = cyclops.RequireComponent <CyclopsDecoyManager>();

            using (packetSender.Suppress <CyclopsChangeSilentRunning>())
            {
                decoyManager.Invoke("LaunchWithDelay", 3f);
                decoyManager.decoyLaunchButton.UpdateText();
                decoyManager.subRoot.voiceNotificationManager.PlayVoiceNotification(decoyManager.subRoot.decoyNotification, false, true);
                decoyManager.subRoot.BroadcastMessage("UpdateTotalDecoys", decoyManager.decoyCount, SendMessageOptions.DontRequireReceiver);
                CyclopsDecoyLaunchButton decoyLaunchButton = cyclops.RequireComponent <CyclopsDecoyLaunchButton>();
                decoyLaunchButton.StartCooldown();
            }
        }
Beispiel #9
0
        public void LaunchDecoy(NitroxId id)
        {
            GameObject          cyclops      = NitroxEntity.RequireObjectFrom(id);
            CyclopsDecoyManager decoyManager = cyclops.RequireComponent <CyclopsDecoyManager>();

            using (packetSender.Suppress <CyclopsChangeSilentRunning>())
            {
                decoyManager.Invoke(nameof(CyclopsDecoyManager.LaunchWithDelay), 3f);
                decoyManager.decoyLaunchButton.UpdateText();
                decoyManager.subRoot.voiceNotificationManager.PlayVoiceNotification(decoyManager.subRoot.decoyNotification, false, true);
                decoyManager.subRoot.BroadcastMessage("UpdateTotalDecoys", decoyManager.decoyCount, SendMessageOptions.DontRequireReceiver);
                CyclopsDecoyLaunchButton decoyLaunchButton = cyclops.RequireComponent <CyclopsDecoyLaunchButton>();
                decoyLaunchButton.StartCooldown();
            }
        }
Beispiel #10
0
        public override void Process(DeconstructionBegin packet)
        {
            GameObject    deconstructing = GuidHelper.RequireObjectFrom(packet.Guid);
            Constructable constructable  = deconstructing.RequireComponent <Constructable>();

            constructable.SetState(false, false);
        }
Beispiel #11
0
        void Init()
        {
            if (hasInit == true)
            {
                return;
            }

            //we assume on first update that the editor subsystem is valid
            GameObject tooltip = GameObject.From(ObjectFactory.getInstance().MakeNewGameObject("EditorMouseTooltip", EditorSubsystem.getInstance().GetEditorState(), true));

            mouseTooltipText = tooltip.RequireComponent <CFontRenderer>();
            mouseTooltipText.mPerspective = false;
            mouseTooltipText.mFontSize    = 12;
            GameObject status = GameObject.From(ObjectFactory.getInstance().MakeNewGameObject("EditorStatusTooltip", EditorSubsystem.getInstance().GetEditorState(), true));

            editorStatusText = status.RequireComponent <CFontRenderer>();
            editorStatusText.mPerspective = false;
            editorStatusText.mFontSize    = 25;
            editorStatusText.mFontScale   = 0.5f;

            hasInit = true;

            //first time script reload when editor in progress
            MochaScriptSystem.ScriptSubsystemManaged.getInstance().Reload();
        }
Beispiel #12
0
    public void RequireComponent()
    {
        var obj = new GameObject("obj");
        var cmp = obj.AddComponent <MockMB>();

        Assert.AreSame(cmp, obj.RequireComponent <MockMB>());
    }
Beispiel #13
0
    void InitMesh()
    {
        if (!hasInit)
        {
            if (gameObject.transform.GetParent() != null)
            {
                hasInit = true;

                camInMapIcon  = gameObject.transform.GetParent().gameObject;
                camInMapMesh  = camInMapIcon.RequireComponent <CForwardRenderer>();
                originalColor = camInMapMesh.GetMaterial().GetColor();

                GameObject cameraCam = Common.GetSurveillancePlayerStaticCameraCam();
                camScript = GetScript <CameraCam>(cameraCam);
                ocuCam    = Common.GetSurveillancePlayerCam();

                sound = gameObject.RequireComponent <CSound>();

                camInMapSelector = Common.GetCameraInMapSelector().RequireComponent <CForwardRenderer>();
                camInMapSelector.setEnabled(false);

                notActiveCamColor1 = new Color(0.1f, 0.1f, 0.1f, 1.0f);
                disabledCamColor1  = new Color(SharpMocha.YELLOW);
                enabledCamColor1   = new Color(SharpMocha.GREEN);

                isVisible = isvisible;
                isActive  = isactive; // To call the set functions
                if (isactive)
                {
                    isEnabled = isenabled;
                }
            }
        }
    }
    public void OnStart()
    {
        //idle.OnEnter = State_Idle_Enter;
        //idle.OnUpdate = State_Idle_Update;
        //idle.OnExit = State_Idle_Exit;
        //
        //jump.OnEnter = State_Jump_Enter;
        //jump.OnUpdate = State_Jump_Update;
        //jump.OnExit = State_Jump_Exit;
        //
        //crouch.OnEnter = State_Crouch_Enter;
        //crouch.OnUpdate = State_Crouch_Update;
        //crouch.OnExit = State_Crouch_Exit;
        //
        //move.OnEnter = State_Move_Enter;
        //move.OnUpdate = State_Move_Update;
        //move.OnExit = State_Move_Exit;
        //
        //smc.SetState(idle);
        //

        // Self
        oculusCam = gameObject.RequireComponent <CCamera>();

        gameCam = GameObject.GetGameObjectByName("Camera").RequireComponent <CCamera>();

        PickCam1 = GameObject.GetGameObjectByName("PickCam1");

        CMeshRenderer mesh = PickCam1.RequireComponent <CMeshRenderer>();

        mesh.setEnabled(false);
    }
    public override void Process(PlayFMODCustomLoopingEmitter packet)
    {
        GameObject            soundSource           = NitroxEntity.RequireObjectFrom(packet.Id);
        FMODEmitterController fmodEmitterController = soundSource.RequireComponent <FMODEmitterController>();

        fmodEmitterController.PlayCustomLoopingEmitter(packet.AssetPath);
    }
Beispiel #16
0
        public void AddItem(GameObject item, NitroxId containerId)
        {
            Optional <GameObject> owner = NitroxEntity.GetObjectFrom(containerId);

            if (!owner.HasValue)
            {
                Log.Info("Unable to find inventory container with id: " + containerId);
                return;
            }
            Optional <ItemsContainer> opContainer = InventoryContainerHelper.GetBasedOnOwnersType(owner.Value);

            if (!opContainer.HasValue)
            {
                Log.Error("Could not find container field on object " + owner.Value.name);
                return;
            }

            ItemsContainer container  = opContainer.Value;
            Pickupable     pickupable = item.RequireComponent <Pickupable>();

            using (packetSender.Suppress <ItemContainerAdd>())
            {
                container.UnsafeAdd(new InventoryItem(pickupable));
            }
        }
    public void OnStart()
    {
        Input.SetMouseVisible(false);
        Input.SetMouseLock(true);

        playerScript = GetScript<FirstPersonPlayer>(Common.GetStealthPlayer());
        rcCarScript = GetScript<RCCar>(Common.GetRCCarJoystick());
        cameraCam = Common.GetSurveillancePlayerStaticCameraCam();
        camScript = GetScript<CameraCam>(cameraCam);
        ocuCam = Common.GetSurveillancePlayerCam();
        prevPickedInteractable = null;
        pickedInteractable = null;
        prevPickedObject = null;
        pickedObject = null;

        camInMapIndex = 0;
        camInMap = Common.GetCamsInMap();

        mCurrMouseMovement = new Vector2(0.0f, 0.0f);
        mMousePositionFromOcuCam = new Vector3(0.0f, 0.0f, 1.3f);
        // Set the mouse cursor position to center of oculus screen
        gameObject.transform.SetPosition(ocuCam.transform.position +
            (Vector3)ocuCam.transform.GetForwardVector() * mMousePositionFromOcuCam.Z);

        // Calculate the limits for the mouse on the ocuScreen
        CCamera ocuCameraComp = ocuCam.RequireComponent<CCamera>();
        mMouseLimits = new Vector2();
        mMouseLimits.X = mMousePositionFromOcuCam.Z / ocuCameraComp.GetNearZ() * ocuCameraComp.GetNearWindowWidth() * 0.5f;
        mMouseLimits.Y = mMousePositionFromOcuCam.Z / ocuCameraComp.GetNearZ() * ocuCameraComp.GetNearWindowHeight() * 0.5f;

        ocuCameraScreen = Common.GetCameraScreen().RequireComponent<CCamera>();
    }
    public void OnStart()
    {
        //idle.OnEnter = State_Idle_Enter;
        //idle.OnUpdate = State_Idle_Update;
        //idle.OnExit = State_Idle_Exit;
        //
        //jump.OnEnter = State_Jump_Enter;
        //jump.OnUpdate = State_Jump_Update;
        //jump.OnExit = State_Jump_Exit;
        //
        //crouch.OnEnter = State_Crouch_Enter;
        //crouch.OnUpdate = State_Crouch_Update;
        //crouch.OnExit = State_Crouch_Exit;
        //
        //move.OnEnter = State_Move_Enter;
        //move.OnUpdate = State_Move_Update;
        //move.OnExit = State_Move_Exit;
        //
        //smc.SetState(idle);
        //

        // Self
        oculusCam = gameObject.RequireComponent<CCamera>();

        gameCam = GameObject.GetGameObjectByName("Camera").RequireComponent<CCamera>();

        PickCam1 = GameObject.GetGameObjectByName("PickCam1");

        CMeshRenderer mesh = PickCam1.RequireComponent<CMeshRenderer>();
        mesh.setEnabled(false);
    }
Beispiel #19
0
        public override void Process(ModuleRemoved packet)
        {
            GameObject           owner       = NitroxIdentifier.RequireObjectFrom(packet.OwnerId);
            GameObject           item        = NitroxIdentifier.RequireObjectFrom(packet.ItemId);
            Pickupable           pickupable  = item.RequireComponent <Pickupable>();
            Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner);

            if (opEquipment.IsPresent())
            {
                Equipment equipment = opEquipment.Get();

                Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                InventoryItem inventoryItem = itemsBySlot[packet.Slot];
                itemsBySlot[packet.Slot] = null;

                equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), false });
                Equipment.SendEquipmentEvent(pickupable, UNEQUIP_EVENT_TYPE_ID, owner, packet.Slot);
                equipment.ReflectionCall("NotifyUnequip", false, false, new object[] { packet.Slot, inventoryItem });
            }
            else
            {
                Log.Error("Could not find equipment type for " + owner.name);
            }

            UnityEngine.Object.Destroy(item);
        }
Beispiel #20
0
    bool isPaperHeld = false; // if true, locks the input to put it down on next L click

    public void OnStart()
    {
        Input.SetMouseVisible(false);
        Input.SetMouseLock(true);

        playerScript           = GetScript <FirstPersonPlayer>(Common.GetStealthPlayer());
        rcCarScript            = GetScript <RCCar>(Common.GetRCCarJoystick());
        cameraCam              = Common.GetSurveillancePlayerStaticCameraCam();
        camScript              = GetScript <CameraCam>(cameraCam);
        ocuCam                 = Common.GetSurveillancePlayerCam();
        prevPickedInteractable = null;
        pickedInteractable     = null;
        prevPickedObject       = null;
        pickedObject           = null;

        camInMapIndex = 0;
        camInMap      = Common.GetCamsInMap();

        mCurrMouseMovement       = new Vector2(0.0f, 0.0f);
        mMousePositionFromOcuCam = new Vector3(0.0f, 0.0f, 1.3f);
        // Set the mouse cursor position to center of oculus screen
        gameObject.transform.SetPosition(ocuCam.transform.position +
                                         (Vector3)ocuCam.transform.GetForwardVector() * mMousePositionFromOcuCam.Z);

        // Calculate the limits for the mouse on the ocuScreen
        CCamera ocuCameraComp = ocuCam.RequireComponent <CCamera>();

        mMouseLimits   = new Vector2();
        mMouseLimits.X = mMousePositionFromOcuCam.Z / ocuCameraComp.GetNearZ() * ocuCameraComp.GetNearWindowWidth() * 0.5f;
        mMouseLimits.Y = mMousePositionFromOcuCam.Z / ocuCameraComp.GetNearZ() * ocuCameraComp.GetNearWindowHeight() * 0.5f;

        ocuCameraScreen = Common.GetCameraScreen().RequireComponent <CCamera>();
    }
        private void SpawnItemContainer(string playerGuid, List <ItemData> inventoryItems)
        {
            Log.Info("Received initial sync packet with " + inventoryItems.Count + " ItemContainer");

            using (packetSender.Suppress <ItemContainerAdd>())
            {
                ItemGoalTracker itemGoalTracker = (ItemGoalTracker)typeof(ItemGoalTracker).GetField("main", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
                Dictionary <TechType, List <ItemGoal> > goals = (Dictionary <TechType, List <ItemGoal> >)(typeof(ItemGoalTracker).GetField("goals", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(itemGoalTracker));

                foreach (ItemData itemdata in inventoryItems)
                {
                    GameObject item       = SerializationHelper.GetGameObject(itemdata.SerializedData);
                    Pickupable pickupable = item.RequireComponent <Pickupable>();
                    goals.Remove(pickupable.GetTechType());  // Remove Notification Goal Event On Item Player Already have On Any Container

                    if (itemdata.ContainerGuid == playerGuid)
                    {
                        ItemsContainer container     = Inventory.Get().container;
                        InventoryItem  inventoryItem = new InventoryItem(pickupable);
                        inventoryItem.container = container;
                        inventoryItem.item.Reparent(container.tr);

                        container.UnsafeAdd(inventoryItem);
                    }
                    else
                    {
                        itemContainers.AddItem(itemdata);
                    }
                }
            }
        }
Beispiel #22
0
        public override void Process(CyclopsActivateHorn hornPacket)
        {
            GameObject         cyclops = GuidHelper.RequireObjectFrom(hornPacket.Guid);
            CyclopsHornControl horn    = cyclops.RequireComponent <CyclopsHornControl>();

            Utils.PlayEnvSound(horn.hornSound, horn.hornSound.gameObject.transform.position, 20f);
        }
Beispiel #23
0
        public void AddItem(ItemData itemData)
        {
            Optional <GameObject> owner = GuidHelper.GetObjectFrom(itemData.ContainerGuid);

            if (owner.IsEmpty())
            {
                Log.Info("Unable to find inventory container with id: " + itemData.ContainerGuid);
                return;
            }

            Optional <ItemsContainer> opContainer = InventoryContainerHelper.GetBasedOnOwnersType(owner.Get());

            if (opContainer.IsPresent())
            {
                ItemsContainer container  = opContainer.Get();
                GameObject     item       = SerializationHelper.GetGameObject(itemData.SerializedData);
                Pickupable     pickupable = item.RequireComponent <Pickupable>();

                using (packetSender.Suppress <ItemContainerAdd>())
                {
                    container.UnsafeAdd(new InventoryItem(pickupable));
                }
            }
            else
            {
                Log.Error("Could not find container field on object " + owner.Get().name);
            }
        }
Beispiel #24
0
        public void AddItem(GameObject item, NitroxId containerId)
        {
            Optional <GameObject> owner = NitroxEntity.GetObjectFrom(containerId);

            if (!owner.HasValue)
            {
                Log.Error($"Unable to find inventory container with id {containerId} for {item.name}");
                return;
            }
            Optional <ItemsContainer> opContainer = InventoryContainerHelper.TryGetContainerByOwner(owner.Value);

            if (!opContainer.HasValue)
            {
                Log.Error($"Could not find container field on GameObject {owner.Value.GetHierarchyPath()}");
                return;
            }

            ItemsContainer container  = opContainer.Value;
            Pickupable     pickupable = item.RequireComponent <Pickupable>();

            using (packetSender.Suppress <ItemContainerAdd>())
            {
                container.UnsafeAdd(new InventoryItem(pickupable));
                Log.Debug($"Received: Added item {pickupable.GetTechType()} to container {owner.Value.GetHierarchyPath()}");
            }
        }
        public override void Process(EquipmentAddItem packet)
        {
            GameObject gameObject = SerializationHelper.GetGameObject(packet.ItemBytes);

            Pickupable           pickupable  = gameObject.RequireComponent <Pickupable>();
            GameObject           owner       = GuidHelper.RequireObjectFrom(packet.OwnerGuid);
            Optional <Equipment> opEquipment = EquipmentHelper.GetBasedOnOwnersType(owner);

            if (opEquipment.IsPresent())
            {
                Equipment     equipment     = opEquipment.Get();
                InventoryItem inventoryItem = new InventoryItem(pickupable);
                inventoryItem.container = equipment;
                inventoryItem.item.Reparent(equipment.tr);

                Dictionary <string, InventoryItem> itemsBySlot = (Dictionary <string, InventoryItem>)equipment.ReflectionGet("equipment");
                itemsBySlot[packet.Slot] = inventoryItem;

                equipment.ReflectionCall("UpdateCount", false, false, new object[] { pickupable.GetTechType(), true });
                Equipment.SendEquipmentEvent(pickupable, EQUIP_EVENT_TYPE_ID, owner, packet.Slot);
                equipment.ReflectionCall("NotifyEquip", false, false, new object[] { packet.Slot, inventoryItem });
            }
            else
            {
                Log.Error("Could not find equipment type for " + gameObject.name);
            }
        }
        public override void Process(ModuleAdded packet)
        {
            EquippedItemData      equippedItemData = packet.EquippedItemData;
            GameObject            gameObject       = SerializationHelper.GetGameObject(equippedItemData.SerializedData);
            Optional <GameObject> opGameObject     = NitroxEntity.GetObjectFrom(equippedItemData.ContainerId);

            if (!opGameObject.HasValue)
            {
                throw new Exception("Could not find equipment container for " + gameObject.name);
            }
            Pickupable           pickupable  = gameObject.RequireComponent <Pickupable>();
            GameObject           owner       = opGameObject.Value;
            Optional <Equipment> opEquipment = EquipmentHelper.FindEquipmentComponent(owner);

            if (!opEquipment.HasValue)
            {
                throw new Exception("Could not find equipment type for " + gameObject.name);
            }

            Equipment     equipment     = opEquipment.Value;
            InventoryItem inventoryItem = new(pickupable);

            inventoryItem.container = equipment;
            inventoryItem.item.Reparent(equipment.tr);

            Dictionary <string, InventoryItem> itemsBySlot = equipment.equipment;

            itemsBySlot[equippedItemData.Slot] = inventoryItem;

            equipment.UpdateCount(pickupable.GetTechType(), true);
            Equipment.SendEquipmentEvent(pickupable, EQUIP_EVENT_TYPE_ID, owner, equippedItemData.Slot);
            equipment.NotifyEquip(equippedItemData.Slot, inventoryItem);
        }
Beispiel #27
0
        private void AssignToWaterPark(String waterParkGuid, Pickupable pickupable)
        {
            GameObject waterParkGo = GuidHelper.RequireObjectFrom(waterParkGuid);
            WaterPark  waterPark   = waterParkGo.RequireComponent <WaterPark>();

            waterPark.AddItem(pickupable);
        }
Beispiel #28
0
        private void DeconstructionBegin(DeconstructionBeginEvent begin)
        {
            GameObject    deconstructing = NitroxEntity.RequireObjectFrom(begin.PieceId);
            Constructable constructable  = deconstructing.RequireComponent <Constructable>();

            constructable.SetState(false, false);
        }
Beispiel #29
0
        private void DeconstructionBegin(DeconstructionBeginEvent begin)
        {
            GameObject    deconstructing = GuidHelper.RequireObjectFrom(begin.Guid);
            Constructable constructable  = deconstructing.RequireComponent <Constructable>();

            constructable.SetState(false, false);
        }
Beispiel #30
0
        public override void Process(ModuleRemoved packet)
        {
            GameObject           owner       = NitroxEntity.RequireObjectFrom(packet.OwnerId);
            Optional <Equipment> opEquipment = EquipmentHelper.FindEquipmentComponent(owner);

            if (!opEquipment.HasValue)
            {
                Log.Error("Could not find equipment type for " + owner.name);
                return;
            }

            GameObject item       = NitroxEntity.RequireObjectFrom(packet.ItemId);
            Pickupable pickupable = item.RequireComponent <Pickupable>();
            Equipment  equipment  = opEquipment.Value;
            Dictionary <string, InventoryItem> itemsBySlot = equipment.equipment;
            InventoryItem inventoryItem = itemsBySlot[packet.Slot];

            itemsBySlot[packet.Slot] = null;

            equipment.UpdateCount(pickupable.GetTechType(), false);
            Equipment.SendEquipmentEvent(pickupable, UNEQUIP_EVENT_TYPE_ID, owner, packet.Slot);
            equipment.NotifyUnequip(packet.Slot, inventoryItem);

            UnityEngine.Object.Destroy(item);
        }
Beispiel #31
0
        public static bool Prefix(Rocket __instance)
        {
            GameObject gameObject = __instance.gameObject;
            NitroxId   id         = NitroxEntity.GetId(gameObject);

            Optional <NeptuneRocketModel> model = NitroxServiceLocator.LocateService <Vehicles>().TryGetVehicle <NeptuneRocketModel>(id);

            if (!model.HasValue)
            {
                Log.Error($"{nameof(Rocket_Start_Patch)}: Could not find NeptuneRocketModel by Nitrox id {id}.\nGO containing wrong id: {__instance.GetHierarchyPath()}");
                return(false);
            }

            __instance.currentRocketStage = model.Value.CurrentStage;

            if (__instance.currentRocketStage > 0)
            {
                __instance.elevatorState    = model.Value.ElevatorUp ? Rocket.RocketElevatorStates.AtTop : Rocket.RocketElevatorStates.AtBottom;
                __instance.elevatorPosition = model.Value.ElevatorUp ? 1f : 0f;
                __instance.SetElevatorPosition();

                //CockpitSwitch and RocketPreflightCheckScreenElement are filled based on the RocketPreflightCheckManager
                if (__instance.currentRocketStage > 3)
                {
                    RocketPreflightCheckManager rocketPreflightCheckManager = gameObject.RequireComponent <RocketPreflightCheckManager>();
                    rocketPreflightCheckManager.preflightChecks.AddRange(model.Value.PreflightChecks);
                }
            }

            return(true);
        }
Beispiel #32
0
        public static void StopAll(GameObject gameObject)
        {
            var tofuAnimator = gameObject.RequireComponent <TofuAnimator>();

            NumSequencesPlaying -= tofuAnimator._activeSequences.Count;
            tofuAnimator._activeSequences.Clear();
            tofuAnimator._toRemove.Clear();
        }
Beispiel #33
0
        // The next two functions could potentially reside outside of this specific serializer.
        // They only happen to be in here because dropped items use this code path.

        private void AssignToWaterPark(GameObject gameObject, string waterParkGuid)
        {
            Pickupable pickupable  = gameObject.RequireComponent <Pickupable>();
            GameObject waterParkGo = GuidHelper.RequireObjectFrom(waterParkGuid);
            WaterPark  waterPark   = waterParkGo.RequireComponent <WaterPark>();

            waterPark.AddItem(pickupable);
        }
Beispiel #34
0
        // The next two functions could potentially reside outside of this specific serializer.
        // They only happen to be in here because dropped items use this code path.

        private void AssignToWaterPark(GameObject gameObject, NitroxId waterParkId)
        {
            Pickupable pickupable  = gameObject.RequireComponent <Pickupable>();
            GameObject waterParkGo = NitroxEntity.RequireObjectFrom(waterParkId);
            WaterPark  waterPark   = waterParkGo.RequireComponent <WaterPark>();

            waterPark.AddItem(pickupable);
        }
    public void OnStart()
    {
        screenImage = GameObject.GetGameObjectByName(Common.prefix + screenImageName);
        screenImageMesh = screenImage.RequireComponent<CMeshRenderer>();
        fadeScreen = GameObject.GetGameObjectByName(Common.prefix + fadeScreenName);
        Common.SetOpacityToGameObject(fadeOpacity, fadeScreen); // Start with full black

        mLoadingState = (int)LOADING_STATE.MENU_DIGIPEN;
        mLoadingTimer = 0.0f;
        mLoadingFirstTime = true;
    }
Beispiel #36
0
    public void OnStart()
    {
        playerCamera = Common.GetStealthPlayerCamera();
        #if ZERO
        Cursor = GameObject.GetGameObjectByName("Mouse");
        //Cursor.SetParent(gameObject);
        Cursor.transform.SetPosition(0, 0, 1.7f, CTransform.TransformSpace.LOCAL);

        zAxis = new Vector3(0, 0, 1);

        MapScreen = GameObject.GetGameObjectByName("MapScreen").RequireComponent<CMeshRenderer>();

        Plane = GameObject.GetGameObjectByName("Plane");
        paperViewer = GetScript<PaperViewer>(Plane);

        SurvCam = GameObject.GetGameObjectByName("Cam_Surv").RequireComponent<CCamera>();
        ocuCam = GameObject.GetGameObjectByName("Cam_Oculus").RequireComponent<CCamera>();

        DoorCode1 = GameObject.GetGameObjectByName("DoorCodes1");
        DoorCode2 = GameObject.GetGameObjectByName("DoorCodes2");

        PickCam1 = GameObject.GetGameObjectByName("PickCam1");
        PickCam2 = GameObject.GetGameObjectByName("PickCam2");
        PickCam3 = GameObject.GetGameObjectByName("PickCam3");
        PickCam4 = GameObject.GetGameObjectByName("PickCam4");
        PickCam5 = GameObject.GetGameObjectByName("PickCam5");
        PickCam6 = GameObject.GetGameObjectByName("PickCam6");

        PickCam1.RequireComponent<CMeshRenderer>().setEnabled(false);
        PickCam2.RequireComponent<CMeshRenderer>().setEnabled(false);
        PickCam3.RequireComponent<CMeshRenderer>().setEnabled(false);
        PickCam4.RequireComponent<CMeshRenderer>().setEnabled(false);
        PickCam5.RequireComponent<CMeshRenderer>().setEnabled(false);
        PickCam6.RequireComponent<CMeshRenderer>().setEnabled(false);

        Input.SetMouseLock(true);
        Input.SetMouseVisible(false);
        #endif
    }
    public void OnStart()
    {
        if (gameObject.transform.GetParent() != null)
        {
            gameObject.transform.SetParent(null);
        }

        speedX = 0;
        speedZ = 0;
        currSpeed = speedNormal;
        speedWhenJumped = 0.0f;

        canJump = true;

        // playerBox is actually my own gameObject
        playerBox = gameObject; // GameObject.GetGameObjectByName("PlayerBoxCollider");
        playerBoxMesh = playerBox.RequireComponent<CMeshRenderer>();
        playerBoxMesh.setEnabled(false);
        playerCamera = Common.GetStealthPlayerCamera();
        playerCamScript = GetScript<FirstPersonCamera>(playerCamera);
        player = Common.GetStealthPlayerMesh();
        anim = player.RequireComponent<CAnimationController>();
        anim.mIsPlaying = true;

        playerPhysics = gameObject.RequireComponent<CPhysics>();
        playerPhysics.mColliderType = 1;

        idle = new State(smc, State_Idle_Enter, State_Idle_Update, State_Idle_Exit);
        move = new State(smc, State_Move_Enter, State_Move_Update, State_Move_Exit);
        jump = new State(smc, State_Jump_Enter, State_Jump_Update, State_Jump_Exit);
        crouch = new State(smc, State_Crouch_Enter, State_Crouch_Update, State_Crouch_Exit);

        sprinting = new State(smc, State_Sprinting_Enter, State_Sprinting_Update, State_Sprinting_Exit, 0.5f);
        sprinting.NextState = sprinting;
        notsprinting = new State(smc, State_NotSprinting_Enter, State_NotSprinting_Update, State_NotSprinting_Exit);

        smc.SetState(idle);
        sprint_smc.SetState(notsprinting);

        footstepID = GetSoundComponent().GetUniqueEvent("P1_FOOTSTEPS.vente", 0);
    }
    public void OnStart()
    {
        sound = gameObject.RequireComponent<CSound>();

        redButton = GameObject.GetGameObjectByName("redButton");
        greenButton = GameObject.GetGameObjectByName("greenButton");
        blueButton = GameObject.GetGameObjectByName("blueButton");
        consoleScreen = Common.GetSurveillancePlayerConsoleScreen();
        consoleScript = GetScript<OcuConsoleScreen>(consoleScreen);
        //lights = GameObject.GetGameObjectsWithTag("phase1light");
        GameObject doorObj = GameObject.GetGameObjectByName("Terminal1Door");
        door1Script = GetScript<DoorMain>(doorObj);
        doorObj = GameObject.GetGameObjectByName("Terminal2Door");
        door2Script = GetScript<DoorMain>(doorObj);

        GameObject checkpoint = GameObject.GetGameObjectByName("Checkpoint1a");
        checkpointScript = GetScript<DeathCheckpointTriggerArea>(checkpoint);
        chilloutFace = GameObject.GetGameObjectByName("chilloutface 1");
        cFace = (chilloutFace.RequireComponent<CMeshRenderer>());

        GameObject lightObj = GameObject.GetGameObjectByName("Light1a");
        lightAtDoor = lightObj.RequireComponent<CLight>();
        lightAtDoor.setEnabled(false);

        foreach (GameObject obj in GameObject.GetGameObjectsWithTag("phase1light"))
        {
            lights.Add(obj.RequireComponent<CLight>());
        }
        sequence.Add(1); sequence.Add(3); sequence.Add(2);
        if(lights.Count == 0)
        {
        }

        geneticsAccessLeftLightObj = GameObject.GetGameObjectByName("GLD_LeftLight");
        geneticsAccessLeftLight = geneticsAccessLeftLightObj.RequireComponent<CLight>();
    }
    public void OnStart()
    {
        mSound = gameObject.RequireComponent<CSound>();
        mSound.PlayIndependentEvent("MUSIC_HUB_LOOP.vente", false, 0);

        menuPointer = GameObject.GetGameObjectByName(Common.prefix + menuPointerName);
        Common.SetOpacityToGameObject(0.0f, menuPointer);
        menuPointerInitPos = new Vector3(-2.75f, 1.23f, -0.11f);
        menuPointer.transform.SetPosition(menuPointerInitPos);
        screenImage = GameObject.GetGameObjectByName(Common.prefix + screenImageName);
        screenImageMesh = screenImage.RequireComponent<CDiffuseRenderer>();
        fadeScreen = GameObject.GetGameObjectByName(Common.prefix + fadeScreenName);
        Common.SetOpacityToGameObject(fadeOpacity, fadeScreen); // Start with full black

        Common.GetMenuFullscreenX().setEnabled(false);
        Common.GetMenuMuteX().setEnabled(false);
        Common.GetMenuVolumeFont().setEnabled(false);

        mLoadingFirstTime = true;
        mPrevMainMenuState = -1;
        mMainMenuState = -1;
    }
    public void OnStart()
    {
        geneticsAccessRightLightObj = GameObject.GetGameObjectByName("GLD_RightLight");
        geneticsAccessRightLight = geneticsAccessRightLightObj.RequireComponent<CLight>();
        geneticsLabDoor = GameObject.GetGameObjectByName("GeneticsLabDoor");
        doorScript = GetScript<DoorMain>(geneticsLabDoor);
        GameObject doorTerminal = GameObject.GetGameObjectByName("Terminal2Door");
        doorTerminalScript = GetScript<DoorMain>(doorTerminal);
        boobyTrapControllerObj = GameObject.GetGameObjectByName("TSR_SeqScrambler");
        boobyTrapScript = GetScript<BoobyTrapControllerScript>(boobyTrapControllerObj);
        GameObject triggerArea = GameObject.GetGameObjectByName("TrapTrigger");
        trapAreaScript = GetScript<ConsoleSequenceInitiator>(triggerArea);

        //ADD SEQUENCES MANUALLY HERE
        List<int> redRoomTrapSeq = new List<int>();
        redRoomTrapSeq.Add(43); redRoomTrapSeq.Add(82); redRoomTrapSeq.Add(13); redRoomTrapSeq.Add(35);
        sequence.validSequence = redRoomTrapSeq;

        sound = gameObject.RequireComponent<CSound>();
    }
    void InitMesh()
    {
        if (!hasInit)
        {
            if (gameObject.transform.GetParent() != null)
            {
                hasInit = true;

                camInMapIcon = gameObject.transform.GetParent().gameObject;
                camInMapMesh = camInMapIcon.RequireComponent<CForwardRenderer>();
                originalColor = camInMapMesh.GetMaterial().GetColor();

                GameObject cameraCam = Common.GetSurveillancePlayerStaticCameraCam();
                camScript = GetScript<CameraCam>(cameraCam);
                ocuCam = Common.GetSurveillancePlayerCam();

                sound = gameObject.RequireComponent<CSound>();

                camInMapSelector = Common.GetCameraInMapSelector().RequireComponent<CForwardRenderer>();
                camInMapSelector.setEnabled(false);

                notActiveCamColor1 = new Color(0.1f, 0.1f, 0.1f, 1.0f);
                disabledCamColor1 = new Color(SharpMocha.YELLOW);
                enabledCamColor1 = new Color(SharpMocha.GREEN);

                isVisible = isvisible;
                isActive = isactive; // To call the set functions
                if (isactive)
                    isEnabled = isenabled;
            }
        }
    }