public override void OnAwake() { base.OnAwake(); respawnWaitAsTicks = ConvertSecsToTicks(respawnDelay); despawnWaitAsTicks = ConvertSecsToTicks(despawnDelay); bitsForTicksUntilRespawn = FloatCrusher.GetBitsForMaxValue((uint)respawnWaitAsTicks); bitsForTicksUntilDespawn = FloatCrusher.GetBitsForMaxValue((uint)despawnWaitAsTicks); }
public void SetTickInterval(float tickInterval) { // Convert seconds into ticks for a more deterministic and networkable count _decayDelayInTicks = (int)(decayDelay / tickInterval); _regenDelayInTicks = (int)(regenDelay / tickInterval); _decayPerTick = decayRate * tickInterval; _regenPerTick = regenRate * tickInterval; bitsForValue = FloatCrusher.GetBitsForMaxValue((uint)_maxValue); bitsForDecayDelay = FloatCrusher.GetBitsForMaxValue((uint)_decayDelayInTicks); bitsForRegenDelay = FloatCrusher.GetBitsForMaxValue((uint)_regenDelayInTicks); }
public override void OnStart() { /// TEST - this code fixed startup rendering, but not fully tested. Likely needs to stay here. ChangeState(new StateChangeInfo(initialState, transform.parent ? transform.parent.GetComponent <Mount>() : null, true)); base.OnStart(); /// Cache values for mountType serialization. We get the total possible mount options from this objects SyncState var mountableToCount = (mountableTo.mask).CountTrueBits(out indexToMountTypeId, MountSettings.Single.mountNames.Count); bitsForMountType = FloatCrusher.GetBitsForMaxValue((uint)(mountableToCount)); for (int i = 0; i < mountableToCount; ++i) { mountTypeIdToIndex.Add(indexToMountTypeId[i], i); } }
public override void OnGUI(Rect r, SerializedProperty property, GUIContent label) { base.OnGUI(r, property, label); if (isExpanded) { int bits = (maskValue).CountTrueBits(MountSettings.Single.mountNames.Count); int serbits = FloatCrusher.GetBitsForMaxValue((uint)(bits)); bitsGC.text = serbits.ToString() + " bits"; reuseGC.text = " "; reuseGC.tooltip = label.tooltip; EditorGUI.LabelField(new Rect(r) { height = LINE_SPACING }, reuseGC, bitsGC, (GUIStyle)"RightLabel"); } }
protected void DrawValueAndBitsNeeded(Rect inner, SerializedProperty sp, float tickduration) { EditorGUI.PropertyField(new Rect(inner) { xMax = inner.xMax - BITS_WIDTH }, sp); if (sp.floatValue < 1) { sp.floatValue = 1; sp.serializedObject.ApplyModifiedProperties(); } int bits = FloatCrusher.GetBitsForMaxValue((uint)(sp.floatValue / tickduration)); EditorGUI.LabelField(new Rect(inner) { xMin = inner.xMax - BITS_WIDTH - 4 }, bits.ToString() + " Bits", miniLabelRight); }
/// <summary> /// Finds all active and inactive colliders on an object /// </summary> /// <param name="netObj"></param> public static void IndexColliders(this NetObject netObj) { var indexed = netObj.indexedColliders; var lookup = netObj.colliderLookup; lookup.Clear(); indexed.Clear(); /// Find ALL components, we will loop through this. netObj.transform.GetNestedComponentsInChildren(reusableComponents); /// Check each component to see if it is a Collider/Collider2D int compCnt = reusableComponents.Count; for (int c = 0; c < compCnt; ++c) { Component comp = reusableComponents[c]; Collider collider = comp as Collider; if (collider) { indexed.Add(comp); } else { Collider2D collider2D = comp as Collider2D; if (collider2D) { indexed.Add(comp); } } } /// Populate the lookup with the found colliders int cnt = indexed.Count; for (int i = 0; i < cnt; ++i) { lookup.Add(indexed[i], i); } netObj.bitsForColliderIndex = FloatCrusher.GetBitsForMaxValue((uint)indexed.Count - 1); }
public void OnAwake() { CollectMounts(); bitsForMountId = (indexedMounts.Count == 0) ? 0 : FloatCrusher.GetBitsForMaxValue((uint)(indexedMounts.Count - 1)); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); serializedObject.Update(); EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); Rect r = EditorGUILayout.GetControlRect(); if (GUI.Button(r, index_Default)) { t.RebuildIndexedNames(); showSummary[uid] = true; } showSummary[uid] = IndentedFoldout(new GUIContent("Indexed Name Summary"), showSummary[uid], 1); if (showSummary[uid]) { sb.Length = 0; sb.Append((uint)t.sharedTriggIndexes.Count).Append(" Triggers found.\n"); for (int i = 0; i < t.sharedTriggIndexes.Count; ++i) { sb.Append(t.sharedTriggNames[i]).Append(" : ").Append(t.sharedTriggIndexes[i]).Append("\n"); } sb.Append(FloatCrusher.GetBitsForMaxValue((uint)t.sharedTriggIndexes.Count - 1) + 1).Append(" bits per indexed Trigger.\n33 bits per non-indexed Trigger.\n\n"); sb.Append((uint)t.sharedStateIndexes.Count).Append(" States found.\n"); for (int i = 0; i < t.sharedStateIndexes.Count; ++i) { sb.Append(t.sharedStateNames[i]).Append(" : ").Append(t.sharedStateIndexes[i]).Append("\n"); } sb.Append(FloatCrusher.GetBitsForMaxValue((uint)t.sharedStateIndexes.Count - 1) + 1).Append(" bits per indexed State.\n33 bits per non-indexed State.\n\n"); //sb.Append((uint)t.sharedTransIndexes.Count).Append(" Transitions found.\n"); //for (int i = 0; i < t.sharedTransIndexes.Count; ++i) // sb.Append(t.sharedTransNames[i]).Append(" : ").Append(t.sharedTransIndexes[i].hash).Append("\n"); //sb.Append(FloatCrusher.GetBitsForMaxValue((uint)t.sharedTransIndexes.Count - 1) + 1).Append(" bits per indexed Transition.\n33 bits per non-indexed Transitions."); EditorGUILayout.HelpBox(sb.ToString(), MessageType.None); } Divider(); /// Passthrus t.syncPassThrus = EditorGUILayout.BeginToggleGroup(passthruLabel, t.syncPassThrus); if (t.syncPassThrus) { NormTimeCompressEnum(EditorGUILayout.GetControlRect(), new GUIContent("Compress NormalizedTime"), ref t.passthruNormTimeCompress); //EditorGUILayout.HelpBox(passThruHelpText, MessageType.None); } EditorGUILayout.EndToggleGroup(); Divider(); /// States t.syncStates = EditorGUILayout.BeginToggleGroup(statesLabel, t.syncStates); if (t.syncStates) { StatesSection(); } EditorGUILayout.EndToggleGroup(); Divider(); /// Layer Weights t.syncLayerWeights = EditorGUILayout.BeginToggleGroup(layerWeightsLabel, t.syncLayerWeights); if (t.syncLayerWeights) { LayerWeightsSection(); } EditorGUILayout.EndToggleGroup(); Divider(); /// Parameters t.syncParams = EditorGUILayout.BeginToggleGroup(paramsLabel, t.syncParams); if (t.syncParams) { ParamSection(); } EditorGUILayout.EndToggleGroup(); EditorGUILayout.Space(); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } }