B9PartSwitch.ModuleB9PartSwitch.IsManagedTransform C# (CSharp) Method

IsManagedTransform() public method

public IsManagedTransform ( Transform transform ) : bool
transform UnityEngine.Transform
return bool
        public bool IsManagedTransform(Transform transform) => ManagedTransforms.Contains(transform);
        public bool IsManagedNode(AttachNode node) => ManagedNodes.Contains(node);

Usage Example

Ejemplo n.º 1
0
        // This runs after OnStart() so everything should be initalized
        public void Start()
        {
            // Check for incompatible modules
            bool modifiedSetup = false;

            List <ModuleB9PartSwitch> otherModules = part.FindModulesImplementing <ModuleB9PartSwitch>();

            for (int i = 0; i < otherModules.Count; i++)
            {
                ModuleB9PartSwitch otherModule = otherModules[i];
                if (otherModule == this)
                {
                    continue;
                }
                bool destroy = false;
                for (int j = 0; j < managedResourceNames.Count; j++)
                {
                    if (otherModule.IsManagedResource(managedResourceNames[j]))
                    {
                        LogError("Two ModuleB9PartSwitch modules cannot manage the same resource: " + managedResourceNames[j]);
                        destroy = true;
                    }
                }
                for (int j = 0; j < managedTransformNames.Count; j++)
                {
                    if (otherModule.IsManagedTransform(managedTransformNames[j]))
                    {
                        LogError("Two ModuleB9PartSwitch modules cannot manage the same transform: " + managedTransformNames[j]);
                        destroy = true;
                    }
                }
                for (int j = 0; j < managedStackNodeIDs.Count; j++)
                {
                    if (otherModule.IsManagedNode(managedStackNodeIDs[j]))
                    {
                        LogError("Two ModuleB9PartSwitch modules cannot manage the same attach node: " + managedStackNodeIDs[j]);
                        destroy = true;
                    }
                }

                if (otherModule.MaxTempManaged && MaxTempManaged)
                {
                    LogError("Two ModuleB9PartSwitch modules cannot both manage the part's maxTemp");
                    destroy = true;
                }

                if (otherModule.SkinMaxTempManaged && SkinMaxTempManaged)
                {
                    LogError("Two ModuleB9PartSwitch modules cannot both manage the part's skinMaxTemp");
                    destroy = true;
                }

                if (otherModule.AttachNodeManaged && AttachNodeManaged)
                {
                    LogError("Two ModuleB9PartSwitch modules cannot both manage the part's attach node");
                    destroy = true;
                }

                if (destroy)
                {
                    LogWarning("ModuleB9PartSwitch with moduleID '" + otherModule.moduleID + "' is incomatible, and will be removed.");
                    part.Modules.Remove(otherModule);
                    Destroy(otherModule);
                    modifiedSetup = true;
                }
            }

            for (int i = 0; i < part.Modules.Count; i++)
            {
                PartModule m = part.Modules[i];
                if (m == null || m is ModuleB9PartSwitch)
                {
                    continue;
                }
                Type mType = m.GetType();

                for (int j = 0; j < IncompatibleModuleTypes.Length; j++)
                {
                    Type testType = IncompatibleModuleTypes[j];
                    if (mType == testType || mType.IsSubclassOf(testType))
                    {
                        LogError("ModuleB9PartSwitch and " + m.moduleName + " cannot exist on the same part.  " + m.moduleName + " will be removed.");
                        part.Modules.Remove(m);
                        Destroy(m);
                        modifiedSetup = true;
                        break;
                    }
                }
            }

            // If there were incompatible modules, they might have messed with things
            if (modifiedSetup)
            {
                UpdateSubtype(false);
            }
        }