示例#1
0
    public void add_Camera()
    {
        GameObject    go       = Instantiate(Globals.Instance.Camera_prefab, Component_Container);
        PropComponent new_comp = new PropComponent(PropComponent.ComponentType.CAMERA, go);

        GetComponent <PropComponentGroup>().components.Add(new_comp);
        Globals.Instance.ComponentList.Add_Component(new_comp);
    }
示例#2
0
    public void add_Collisiondetection()
    {
        GameObject    go       = Instantiate(Globals.Instance.CollisionDetection_prefab, Component_Container);
        PropComponent new_comp = new PropComponent(PropComponent.ComponentType.COLLISIONDETECTION, go);

        GetComponent <PropComponentGroup>().components.Add(new_comp);
        Globals.Instance.ComponentList.Add_Component(new_comp);
    }
示例#3
0
    public void add_LaserScanner()
    {
        GameObject    go       = Instantiate(Globals.Instance.LaserScanner_prefab, Component_Container);
        PropComponent new_comp = new PropComponent(PropComponent.ComponentType.LASERSCANNER, go);

        GetComponent <PropComponentGroup>().components.Add(new_comp);
        Globals.Instance.ComponentList.Add_Component(new_comp);
    }
示例#4
0
        private void InitializeProps()
        {
            helmetsComponents = new Dictionary <string, HelmetComponent>();
            propComponents    = new Dictionary <string, PropComponent>();

            foreach (var partProp in props)
            {
                ModuleWearableProp module          = partProp.Value;
                Transform          attachTransform = Utilities.GetTransformAlias(kerbal, module.attachTransform);
                GameObject         partPrefab      = module.part.partInfo.partPrefab.FindModelTransform("model").gameObject;

                Vector3    positionOffset = attachTransform.TransformPoint(module.positionOffset);
                Quaternion rotationOffset = attachTransform.rotation * Quaternion.Euler(module.rotationOffset);

                GameObject prop = Instantiate(partPrefab, positionOffset, rotationOffset, kerbal.transform);
                prop.name = module.moduleId;

                TrackRigidbody trackRigidbody = prop.gameObject.AddComponent <TrackRigidbody>();
                trackRigidbody.attachTransform = attachTransform;
                trackRigidbody.positionOffset  = module.positionOffset;
                trackRigidbody.rotationOffset  = module.rotationOffset;
                prop.SetActive(false);

                List <Collider> colliders = prop.GetComponentsInChildren <Collider>(true).ToList();
                foreach (Collider collider in colliders)
                {
                    DestroyImmediate(collider);
                }

                List <Light> lights = new List <Light>();
                if (Utilities.CheckForLights(prop, out lights))
                {
                    lights = lights.Where(l => module.lightNames.Contains(l.name)).ToList();
                }

                if (module.propType == PropType.HELMET)
                {
                    HelmetComponent helmetComponent = prop.AddComponent <HelmetComponent>();
                    helmetComponent.kerbal = this.kerbal;
                    helmetComponent.lights = lights;
                    helmetComponent.module = module;
                    helmetsComponents.Add(partProp.Key, helmetComponent);
                }
                else
                {
                    PropComponent propComponent = prop.AddComponent <PropComponent>();
                    propComponent.isHelmetAttachment = module.propType == PropType.HELMETPROP ? true : false;
                    propComponent.kerbal             = this.kerbal;
                    propComponent.lights             = lights;
                    propComponent.module             = module;
                    propComponents.Add(partProp.Key, propComponent);
                }
            }

            isInitialized = true;
        }
    private void CheckForPropDisabling(GameObject prop)
    {
        RoomItem internalProp = currentRoom.roomItemsList.Find(item => item._name == prop.name);

        prop.GetComponent <BoxCollider>().enabled = internalProp.isEnabled;
        PropComponent propData = prop.GetComponent <PropComponent>();

        if (PhaseManager.currentPhase.phaseIndex >= propData.requiredPhase.phaseIndex)
        {
            prop.GetComponent <BoxCollider>().enabled = true;
            internalProp.isEnabled = true;
            //EditorUtility.SetDirty(currentRoom);
        }
    }
示例#6
0
 public void setComponent(PropComponent comp)
 {
     foreach (ComponentPanel p in panels)
     {
         if (p.cType == comp.type)
         {
             p.panel.GetComponent <CP_PanelController>().set_reference(comp.reference.transform);
             p.panel.gameObject.SetActive(true);
         }
         else
         {
             p.panel.gameObject.SetActive(false);
         }
     }
 }
示例#7
0
    public void Add_Component(PropComponent comp)
    {
        RectTransform ne = Instantiate(ListEntryPrefab, transform);

        entries.Add(ne.GetComponent <UIListEntry>());

        if (AddEntryButton)
        {
            AddEntryButton.SetAsLastSibling();
        }

        UIListEntry_Component lep = ne.GetComponent <UIListEntry_Component>();

        if (!lep)
        {
            Globals.Instance.DevConsole.error("Attempted to Add Prop to UIList, but Prefab does not include a UIListEntry_Component Component!"); return;
        }
        else
        {
            lep.reference = comp;
        }
    }