/// <summary> /// Wraps a GameObject into a Node /// </summary> /// <param name="injector"></param> /// <param name="gameObject"></param> internal ObjectNode(Injector injector, GameObject gameObject) : base(injector) { this.gameObject = gameObject; this.hashes = new Dictionary <Type, long>(); }
/// <summary> /// Creates serializable Component from Unity component /// </summary> /// <param name="injector"></param> /// <param name="component"></param> public AbstractComponent(Injector injector, Component component) { this.injector = injector; }
/// <summary> /// Function to find valid rule for Component from GameObject /// </summary> /// <param name="injector"></param> /// <param name="gameObject"></param> /// <param name="type"></param> /// <param name="updateType"></param> /// <returns></returns> internal static bool FindComponentRule(Injector injector, GameObject gameObject, Type type, UpdateType updateType) { // Find relevant rule Transform pointer = gameObject.transform; do { // See if current GameObject has a NetworkModel Rule component NetworkModelRule networkModelRule = pointer.GetComponent <NetworkModelRule>(); // If true, then a rule was found if (networkModelRule != null) { // Check if the Rule was found in the passed GameObject if (gameObject.transform == pointer) { // Check if the Rule is active for the GameObject it is attached to if (networkModelRule.applyToObject) { // Get the correct Rule RuleType ruleType = CheckComponentRule(networkModelRule, type, updateType); // Check, if Rule is enabled if (ruleType != RuleType.DISABLED) { return(ruleType.ToBool()); } } else { // Rule does not apply, continue with parent GameObject pointer = pointer.parent; continue; } } // ELse, the Rule was found in a parent GameObject else { // Check if the Rule is active for the GameObject it is attached to if (networkModelRule.applyToChildren) { // Get the correct Rule RuleType ruleType = CheckComponentRule(networkModelRule, type, updateType); // Check, if Rule is enabled if (ruleType != RuleType.DISABLED) { return(ruleType.ToBool()); } } else { // Rule does not apply, continue with parent GameObject pointer = pointer.parent; continue; } } } // Go one GameObject up in Hierarchy pointer = pointer.parent; } while (pointer != null); LogUtility.Log(injector, LogType.INFORMATION, "No active rule found for Type " + type); // Default value return(RuleUtility.DEFAULT_RULE); }